fix(voice): re-check voice status on tab visibility change and after saving voice settings
This commit is contained in:
@@ -25,6 +25,15 @@ function startAppServices() {
|
|||||||
settingsStore.checkVoiceStatus();
|
settingsStore.checkVoiceStatus();
|
||||||
// Sync browser timezone to the server on every login/page load.
|
// Sync browser timezone to the server on every login/page load.
|
||||||
apiPut("/api/settings", { user_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone }).catch(() => {});
|
apiPut("/api/settings", { user_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone }).catch(() => {});
|
||||||
|
// Re-check voice status when the tab becomes visible again (model may
|
||||||
|
// have finished loading while the user was away).
|
||||||
|
document.addEventListener("visibilitychange", onVisibilityChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onVisibilityChange() {
|
||||||
|
if (document.visibilityState === "visible" && authStore.isAuthenticated) {
|
||||||
|
settingsStore.checkVoiceStatus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopAppServices() {
|
function stopAppServices() {
|
||||||
@@ -150,6 +159,7 @@ watch(
|
|||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
document.removeEventListener("keydown", onGlobalKeydown);
|
document.removeEventListener("keydown", onGlobalKeydown);
|
||||||
|
document.removeEventListener("visibilitychange", onVisibilityChange);
|
||||||
stopAppServices();
|
stopAppServices();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -500,6 +500,8 @@ async function saveAdminVoice() {
|
|||||||
adminVoiceSaved.value = true;
|
adminVoiceSaved.value = true;
|
||||||
setTimeout(() => { adminVoiceSaved.value = false; }, 2000);
|
setTimeout(() => { adminVoiceSaved.value = false; }, 2000);
|
||||||
voiceTabLoaded.value = false;
|
voiceTabLoaded.value = false;
|
||||||
|
// Always update global voice state so mic buttons appear/disappear immediately
|
||||||
|
await store.checkVoiceStatus();
|
||||||
if (adminVoiceEnabled.value) {
|
if (adminVoiceEnabled.value) {
|
||||||
await reloadVoiceModels();
|
await reloadVoiceModels();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user