Simplify how video call layout is stored

This commit is contained in:
mplorentz
2026-04-07 14:57:24 -04:00
committed by hodlbod
parent fb60d493b9
commit 2c4fe7bcf3
7 changed files with 93 additions and 77 deletions
+11 -9
View File
@@ -87,15 +87,17 @@ export const voiceState = writable<VoiceState>(VoiceState.Disconnected)
export const currentVoiceRoom = writable<Room | undefined>(undefined)
/** Mobile room UI: full-screen chat vs video (see VoiceWidget layout toggle). */
export const voiceMobileRoomPanel = writable<"chat" | "video">("chat")
/** Chat-only, full-width video, or split (desktop). On narrow viewports, `split` shows as chat until resize remaps it. */
export enum VideoCallLayout {
Chat = "chat",
Video = "video",
Split = "split",
}
/** Desktop room UI: messages only, video only, or split (see VoiceWidget layout toggle). */
export const voiceDesktopRoomPanel = writable<"chat" | "video" | "split">("split")
export const videoCallLayout = writable<VideoCallLayout>(VideoCallLayout.Split)
const resetVoiceRoomPanels = () => {
voiceMobileRoomPanel.set("chat")
voiceDesktopRoomPanel.set("chat")
const resetVideoCallLayout = () => {
videoCallLayout.set(VideoCallLayout.Chat)
}
export const participantPubkeyMap = writable<Map<string, Pubkey>>(new Map())
@@ -240,7 +242,7 @@ const onRoomDisconnected = (reason?: DisconnectReason) => {
videoCallLayoutRevision.set(0)
videoPrimaryTileKey.set(undefined)
currentVoiceSession.set(undefined)
resetVoiceRoomPanels()
resetVideoCallLayout()
if (reason !== undefined && reason !== DisconnectReason.CLIENT_INITIATED) {
voiceState.set(VoiceState.Disconnected)
const message =
@@ -408,7 +410,7 @@ export const leaveVoiceRoom = async () => {
videoCallLayoutRevision.set(0)
videoPrimaryTileKey.set(undefined)
currentVoiceSession.set(undefined)
resetVoiceRoomPanels()
resetVideoCallLayout()
session.room.disconnect()
speakingParticipants.set([])
participantPubkeyMap.set(new Map())