mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 01:42:50 +08:00
Add per-event checkbox to mute individual sound notifications
Lets users disable e.g. join/leave chimes while keeping others on, without touching the master sounds toggle. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7a69d8602c
commit
234feb4d55
3 files changed
+32
No files matched your search
@@ -4,6 +4,7 @@ export const SOUND_EVENTS: SoundEventId[] = ["connect", "disconnect", "clientJoi
|
||||
|
||||
const ENABLED_KEY = "webspeak3:sounds-enabled";
|
||||
const VOLUME_KEY = "webspeak3:sounds-volume";
|
||||
const EVENT_ENABLED_KEY_PREFIX = "webspeak3:sounds-enabled:";
|
||||
const DB_NAME = "webspeak3-sounds";
|
||||
const STORE_NAME = "custom";
|
||||
|
||||
@@ -66,6 +67,15 @@ export function saveSoundsEnabled(enabled: boolean): void {
|
||||
localStorage.setItem(ENABLED_KEY, String(enabled));
|
||||
}
|
||||
|
||||
export function loadEventSoundEnabled(event: SoundEventId): boolean {
|
||||
const raw = localStorage.getItem(EVENT_ENABLED_KEY_PREFIX + event);
|
||||
return raw === null ? true : raw === "true";
|
||||
}
|
||||
|
||||
export function saveEventSoundEnabled(event: SoundEventId, enabled: boolean): void {
|
||||
localStorage.setItem(EVENT_ENABLED_KEY_PREFIX + event, String(enabled));
|
||||
}
|
||||
|
||||
export function loadSoundsVolume(): number {
|
||||
const raw = localStorage.getItem(VOLUME_KEY);
|
||||
const n = raw ? Number(raw) : 0.5;
|
||||
@@ -196,6 +206,7 @@ export function setSoundsOutputDevice(deviceId: string): void {
|
||||
|
||||
export async function playSound(event: SoundEventId): Promise<void> {
|
||||
if (!loadSoundsEnabled()) return;
|
||||
if (!loadEventSoundEnabled(event)) return;
|
||||
const volume = loadSoundsVolume();
|
||||
const custom = await loadCustomSound(event).catch(() => undefined);
|
||||
if (custom) {
|
||||
|
||||
Reference in new issue
Block a user