Revert changes from bugfix/voice-room-membership-error
This commit is contained in:
+2
-21
@@ -16,30 +16,12 @@ import type {TrustedEvent} from "@welshman/util"
|
|||||||
import {makeHttpAuth, makeHttpAuthHeader, getTags} from "@welshman/util"
|
import {makeHttpAuth, makeHttpAuthHeader, getTags} from "@welshman/util"
|
||||||
import {signer} from "@welshman/app"
|
import {signer} from "@welshman/app"
|
||||||
import {getLivekitEndpoint} from "$lib/livekit"
|
import {getLivekitEndpoint} from "$lib/livekit"
|
||||||
import {AbortError, TimeoutError, whenAborted, whenTimeout} from "$lib/util"
|
import {AbortError, whenAborted, whenTimeout} from "$lib/util"
|
||||||
import {deriveLatestEventForUrl, type RoomRef} from "@app/core/state"
|
import {deriveLatestEventForUrl, type RoomRef} from "@app/core/state"
|
||||||
import {pushToast} from "@app/util/toast"
|
import {pushToast} from "@app/util/toast"
|
||||||
|
|
||||||
export const LIVEKIT_PARTICIPANTS = 39004
|
export const LIVEKIT_PARTICIPANTS = 39004
|
||||||
|
|
||||||
export class VoiceJoinMembershipError extends Error {
|
|
||||||
constructor() {
|
|
||||||
super("Failed to join voice room: you must be a member.")
|
|
||||||
this.name = "VoiceJoinMembershipError"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 VoiceJoinMembershipError) message = e.message
|
|
||||||
else if (e instanceof TimeoutError)
|
|
||||||
message = "Connection timed out. Please check your network and try again."
|
|
||||||
else if (e instanceof Error && e.message === "No signer available") message = e.message
|
|
||||||
pushToast({theme: "error", message})
|
|
||||||
}
|
|
||||||
|
|
||||||
export {checkRelayHasLivekit} from "$lib/livekit"
|
export {checkRelayHasLivekit} from "$lib/livekit"
|
||||||
|
|
||||||
export type VoiceSession = {
|
export type VoiceSession = {
|
||||||
@@ -124,7 +106,6 @@ const fetchLivekitToken = async (
|
|||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const text = await response.text()
|
const text = await response.text()
|
||||||
if (response.status === 403) throw new VoiceJoinMembershipError()
|
|
||||||
throw new Error(`Token request failed (${response.status}): ${text}`)
|
throw new Error(`Token request failed (${response.status}): ${text}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,7 +277,7 @@ export const joinVoiceRoom = async (
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (isActive()) voiceState.set(VoiceState.Disconnected)
|
if (isActive()) voiceState.set(VoiceState.Disconnected)
|
||||||
if (e instanceof AbortError) return
|
if (e instanceof AbortError) return
|
||||||
handleJoinError(e)
|
throw e
|
||||||
} finally {
|
} finally {
|
||||||
if (isActive()) joinAbortController = undefined
|
if (isActive()) joinAbortController = undefined
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user