Add mute persistence

This commit is contained in:
dwrz
2026-07-05 18:00:10 +00:00
parent 1e4c7f0334
commit d24013269a

View File

@@ -15,6 +15,7 @@ import { WakeLock } from './wakelock.js';
const STREAM_ENDPOINT = '/v1/chat/voice/stream'; const STREAM_ENDPOINT = '/v1/chat/voice/stream';
const SYSTEM_MESSAGE_KEY = 'odidere_system_message'; const SYSTEM_MESSAGE_KEY = 'odidere_system_message';
const MAX_TURNS_KEY = 'odidere_max_turns'; const MAX_TURNS_KEY = 'odidere_max_turns';
const MUTE_KEY = 'odidere_mute';
const ICONS_URL = '/static/icons.svg'; const ICONS_URL = '/static/icons.svg';
const StreamEventDelta = 'delta'; const StreamEventDelta = 'delta';
@@ -128,6 +129,15 @@ class Odidere {
this.settings.fetchVoices(); this.settings.fetchVoices();
this.settings.fetchModels(); this.settings.fetchModels();
this.updateSendButtonState(); this.updateSendButtonState();
// Restore mute state
const storedMute = localStorage.getItem(MUTE_KEY);
if (storedMute === 'true') {
this.isMuted = true;
this.tts.setMuted(true);
this.$mute.replaceChildren(this._icon('volume-off'));
this.$mute.classList.add('footer__toolbar-btn--muted');
this.$mute.setAttribute('aria-label', 'Unmute');
}
this._initVisualViewport(); this._initVisualViewport();
} }
@@ -1024,6 +1034,7 @@ class Odidere {
toggleMute() { toggleMute() {
this.isMuted = !this.isMuted; this.isMuted = !this.isMuted;
localStorage.setItem(MUTE_KEY, String(this.isMuted));
const iconName = this.isMuted ? 'volume-off' : 'volume'; const iconName = this.isMuted ? 'volume-off' : 'volume';
this.$mute.replaceChildren(this._icon(iconName)); this.$mute.replaceChildren(this._icon(iconName));
this.$mute.classList.toggle('footer__toolbar-btn--muted', this.isMuted); this.$mute.classList.toggle('footer__toolbar-btn--muted', this.isMuted);