fix: PTT blur/unmute, EC button hiding robustness, PTT status indicator
This commit is contained in:
@@ -58,14 +58,18 @@ export function CallControls({ callEmbed }: CallControlsProps) {
|
||||
const [pttKey] = useSetting(settingsAtom, 'pttKey');
|
||||
const [pttActive, setPttActive] = useState(false);
|
||||
|
||||
// Mute mic immediately when PTT is enabled mid-call so the key handler can activate
|
||||
// Handle PTT mode toggle mid-call
|
||||
const pttModeRef = useRef(pttMode);
|
||||
useEffect(() => {
|
||||
if (pttMode && !pttModeRef.current && microphone) {
|
||||
if (pttMode && !pttModeRef.current) {
|
||||
// PTT just enabled — mute mic so key handler can activate
|
||||
callEmbed.control.setMicrophone(false);
|
||||
} else if (!pttMode && pttModeRef.current) {
|
||||
// PTT just disabled — restore mic to on
|
||||
callEmbed.control.setMicrophone(true);
|
||||
}
|
||||
pttModeRef.current = pttMode;
|
||||
}, [pttMode, callEmbed, microphone]);
|
||||
}, [pttMode, callEmbed]);
|
||||
|
||||
const handleOpenMenu: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
setCords(evt.currentTarget.getBoundingClientRect());
|
||||
@@ -101,11 +105,18 @@ export function CallControls({ callEmbed }: CallControlsProps) {
|
||||
setPttActive(false);
|
||||
}
|
||||
};
|
||||
// Release PTT if the tab loses focus — prevents mic getting stuck on after tab switching
|
||||
const onBlur = () => {
|
||||
callEmbed.control.setMicrophone(false);
|
||||
setPttActive(false);
|
||||
};
|
||||
window.addEventListener('keydown', onKeyDown);
|
||||
window.addEventListener('keyup', onKeyUp);
|
||||
window.addEventListener('blur', onBlur);
|
||||
return () => {
|
||||
window.removeEventListener('keydown', onKeyDown);
|
||||
window.removeEventListener('keyup', onKeyUp);
|
||||
window.removeEventListener('blur', onBlur);
|
||||
};
|
||||
}, [pttMode, pttKey, callEmbed, microphone]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user