/** * Per-member output volume lives in the browser, not on the server: the tile menu * writes it while the user drags the slider, and the deafen toggle reads the same * keys back when the sound comes on again. Both go through this module so the * storage format cannot drift between them. */ const VOLUME_PREFIX = 'gitdata.voice.volume.' /** Remembered volume for one member; 1 when nothing usable is stored. */ export function rememberedVolume(roomId: string | null, identity: string): number { if (!roomId) return 1 try { const raw = Number(localStorage.getItem(VOLUME_PREFIX + roomId + '.' + identity)) return Number.isFinite(raw) && raw > 0 ? raw : 1 } catch { return 1 } } /** Persist one member's volume. Best effort: memory is a convenience. */ export function rememberVolume(roomId: string, identity: string, volume: number): void { try { localStorage.setItem(VOLUME_PREFIX + roomId + '.' + identity, String(volume)) } catch { // Volume memory is a convenience, never a requirement. } }