Apply PTT patch to modern element call

This commit is contained in:
David Baker
2023-01-19 17:26:27 +00:00
parent 9437a00997
commit b9c5fe3c0f

View File

@@ -247,6 +247,26 @@ export const usePTT = (
setMicMuteWrapper(true);
}, [setMicMuteWrapper]);
const onMessage = useCallback(
(e) => {
console.log("got message", e);
if (e.data === "pttp") {
startTalking();
} else if (e.data === "pttr") {
stopTalking();
}
},
[startTalking, stopTalking]
);
useEffect(() => {
window.addEventListener("message", onMessage);
return () => {
window.removeEventListener("message", onMessage);
};
});
// separate state for connected: we set it separately from other things
// in the client sync callback
const [connected, setConnected] = useState(true);