feat(companion-app): ✨ Implement new settings management props and state in CompanionApp.tsx for user configuration
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
492d724ca8
commit
884179d25f
1 changed files with 21 additions and 0 deletions
|
|
@ -168,6 +168,27 @@ function CompanionAppInner(): ReactElement {
|
|||
const activeAssistantIdRef = useRef<string | null>(null);
|
||||
const audioInitializedRef = useRef(false);
|
||||
|
||||
// SW → client audio message (notification tap with audioUrl)
|
||||
useEffect(() => {
|
||||
if (!('serviceWorker' in navigator)) return;
|
||||
const handler = (event: MessageEvent<unknown>) => {
|
||||
if (
|
||||
event.data !== null &&
|
||||
typeof event.data === 'object' &&
|
||||
'type' in event.data &&
|
||||
(event.data as { type: unknown }).type === 'play-tts' &&
|
||||
'url' in event.data &&
|
||||
typeof (event.data as { url: unknown }).url === 'string'
|
||||
) {
|
||||
const audioUrl = (event.data as { url: string }).url;
|
||||
const audio = new Audio(audioUrl);
|
||||
audio.play().catch(() => {/* autoplay may be blocked — user will still see the notification */});
|
||||
}
|
||||
};
|
||||
navigator.serviceWorker.addEventListener('message', handler);
|
||||
return () => navigator.serviceWorker.removeEventListener('message', handler);
|
||||
}, []);
|
||||
|
||||
// PWA install prompt
|
||||
const installPromptRef = useRef<Event | null>(null);
|
||||
useEffect(() => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue