feature/23-voice-room/poc #93

Merged
hodlbod merged 68 commits from feature/23-voice-room/poc into dev 2026-03-16 20:38:06 +00:00
Showing only changes of commit 25228f785d - Show all commits
+17 -4
View File
4
@@ -168,13 +168,15 @@ export const joinVoiceRoom = async (
throw e
}
let muted = false
try {
await room.localParticipant.setMicrophoneEnabled(true)
} catch (e) {
muted = true
pushToast({theme: "error", message: "Could not access microphone"})
}
currentVoiceSession.set({url, h, room, muted: false})
currentVoiceSession.set({url, h, room, muted})
startPresenceHeartbeat(url, h)
}
@@ -190,11 +192,22 @@ export const leaveVoiceRoom = async () => {
currentVoiceSession.set(undefined)
}
export const toggleMute = () => {
export const toggleMute = async () => {
const session = get(currentVoiceSession)
if (!session) return
hodlbod marked this conversation as resolved Outdated
Outdated
Review

This will never happen because there are no awaits between this and the previous check.

The if (signal) is redundant too, we should just require the caller to provide a signal.

This will never happen because there are no awaits between this and the previous check. The if (signal) is redundant too, we should just require the caller to provide a signal.
const muted = !session.muted
session.room.localParticipant.setMicrophoneEnabled(!muted)
currentVoiceSession.set({...session, muted})
if (muted) {
// Disable and re-enable microphone to trigger permission prompt
session.room.localParticipant.setMicrophoneEnabled(false)
currentVoiceSession.set({...session, muted})
return
}
try {
await session.room.localParticipant.setMicrophoneEnabled(true)
currentVoiceSession.set({...session, muted})
} catch (e) {
pushToast({theme: "error", message: "Could not access microphone"})
}
}