Revert changes from bugfix/voice-room-membership-error

This commit is contained in:
mplorentz
2026-03-27 11:07:52 -04:00
parent bd0adfdffe
commit 51bd33556d
+2 -21
View File
@@ -16,30 +16,12 @@ import type {TrustedEvent} from "@welshman/util"
import {makeHttpAuth, makeHttpAuthHeader, getTags} from "@welshman/util"
import {signer} from "@welshman/app"
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 {pushToast} from "@app/util/toast"
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 type VoiceSession = {
@@ -124,7 +106,6 @@ const fetchLivekitToken = async (
if (!response.ok) {
const text = await response.text()
if (response.status === 403) throw new VoiceJoinMembershipError()
throw new Error(`Token request failed (${response.status}): ${text}`)
}
@@ -296,7 +277,7 @@ export const joinVoiceRoom = async (
} catch (e) {
if (isActive()) voiceState.set(VoiceState.Disconnected)
if (e instanceof AbortError) return
handleJoinError(e)
throw e
} finally {
if (isActive()) joinAbortController = undefined
}