Files
cinny/src/app/hooks/useTauriCallPower.ts
T

19 lines
714 B
TypeScript
Raw Normal View History

import { useEffect } from 'react';
import { useAtomValue } from 'jotai';
import { callEmbedAtom } from '../state/callEmbed';
import { invokeTauri } from './useTauri';
/**
* P5-46 — keep the system awake during calls (call continuity). Mirrors the
* call-embed atom (undefined = no active call) onto the native `set_call_active`
* command, which holds a `SetThreadExecutionState` request on Windows while a
* voice/video call is active and releases it when the call ends. No-op in the
* browser.
*/
export function useTauriCallPower(): void {
const callEmbed = useAtomValue(callEmbedAtom);
useEffect(() => {
invokeTauri('set_call_active', { active: callEmbed !== undefined });
}, [callEmbed]);
}