Move handleJoinerror into VoiceRoomJoinDialog.
This commit is contained in:
@@ -12,10 +12,11 @@
|
|||||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||||
import ModalSubtitle from "@lib/components/ModalSubtitle.svelte"
|
import ModalSubtitle from "@lib/components/ModalSubtitle.svelte"
|
||||||
import ModalTitle from "@lib/components/ModalTitle.svelte"
|
import ModalTitle from "@lib/components/ModalTitle.svelte"
|
||||||
|
import {AbortError, TimeoutError} from "$lib/util"
|
||||||
import {displayRoom} from "@app/core/state"
|
import {displayRoom} from "@app/core/state"
|
||||||
import {handleJoinError} from "@app/components/VoiceWidget.svelte"
|
|
||||||
import {joinVoiceRoom} from "@app/voice"
|
import {joinVoiceRoom} from "@app/voice"
|
||||||
import {popModal} from "@app/util/modal"
|
import {popModal} from "@app/util/modal"
|
||||||
|
import {pushToast} from "@app/util/toast"
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
url: string
|
url: string
|
||||||
@@ -46,6 +47,16 @@
|
|||||||
|
|
||||||
const goBack = () => history.back()
|
const goBack = () => history.back()
|
||||||
|
|
||||||
|
const handleJoinError = (e: unknown) => {
|
||||||
|
if (e instanceof AbortError) return
|
||||||
|
console.error("Failed to join voice room", e)
|
||||||
|
let message = "Failed to join voice room"
|
||||||
|
if (e instanceof TimeoutError)
|
||||||
|
message = "Connection timed out. Please check your network and try again."
|
||||||
|
else if (e instanceof Error) message = e.message
|
||||||
|
pushToast({theme: "error", message})
|
||||||
|
}
|
||||||
|
|
||||||
const joinVoice = async () => {
|
const joinVoice = async () => {
|
||||||
popModal()
|
popModal()
|
||||||
await joinVoiceRoom(
|
await joinVoiceRoom(
|
||||||
|
|||||||
@@ -1,18 +1,3 @@
|
|||||||
<script module lang="ts">
|
|
||||||
import {AbortError, TimeoutError} from "$lib/util"
|
|
||||||
import {pushToast} from "@app/util/toast"
|
|
||||||
|
|
||||||
export function handleJoinError(e: unknown) {
|
|
||||||
if (e instanceof AbortError) return
|
|
||||||
console.error("Failed to join voice room", e)
|
|
||||||
let message = "Failed to join voice room"
|
|
||||||
if (e instanceof TimeoutError)
|
|
||||||
message = "Connection timed out. Please check your network and try again."
|
|
||||||
else if (e instanceof Error) message = e.message
|
|
||||||
pushToast({theme: "error", message})
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {readable} from "svelte/store"
|
import {readable} from "svelte/store"
|
||||||
import {fly} from "svelte/transition"
|
import {fly} from "svelte/transition"
|
||||||
|
|||||||
Reference in New Issue
Block a user