mirror of
https://github.com/vector-im/element-call.git
synced 2026-03-19 06:20:25 +00:00
Experimental patch bridging postmessage events to PTT button
Listen for events on postmessage & use them to press the PTT button
This commit is contained in:
@@ -246,6 +246,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);
|
||||
|
||||
Reference in New Issue
Block a user