feat(dictation): add persistent language selection in General settings

This commit is contained in:
Bartosz Chronowki
2026-10-25 14:33:49 +01:00
parent b277ee3e0f
commit 3bb28e5f29
18 changed files with 1158 additions and 72 deletions
+25
View File
@@ -0,0 +1,25 @@
"use client";
import { useSyncExternalStore } from "react";
// The keyboard chain needs a synchronous answer; settings also subscribe
// so the language control locks from connecting until cleanup completes.
let active = false;
const listeners = new Set<() => void>();
export function isDictationActive(): boolean { return active; }
export function setDictationActive(next: boolean): void {
if (active === next) return;
active = next;
for (const listener of listeners) listener();
}
function subscribe(listener: () => void): () => void {
listeners.add(listener);
return () => { listeners.delete(listener); };
}
export function useDictationActive(): boolean {
return useSyncExternalStore(subscribe, isDictationActive, () => false);
}