Split out client sync listeber into separate useEffect
This commit is contained in:
parent
64e30c89e3
commit
d9bd48b9a6
1 changed files with 8 additions and 4 deletions
|
@ -262,14 +262,10 @@ export const usePTT = (
|
||||||
window.addEventListener("keyup", onKeyUp);
|
window.addEventListener("keyup", onKeyUp);
|
||||||
window.addEventListener("blur", onBlur);
|
window.addEventListener("blur", onBlur);
|
||||||
|
|
||||||
client.on(ClientEvent.Sync, onClientSync);
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener("keydown", onKeyDown);
|
window.removeEventListener("keydown", onKeyDown);
|
||||||
window.removeEventListener("keyup", onKeyUp);
|
window.removeEventListener("keyup", onKeyUp);
|
||||||
window.removeEventListener("blur", onBlur);
|
window.removeEventListener("blur", onBlur);
|
||||||
|
|
||||||
client.removeListener(ClientEvent.Sync, onClientSync);
|
|
||||||
};
|
};
|
||||||
}, [
|
}, [
|
||||||
groupCall,
|
groupCall,
|
||||||
|
@ -285,6 +281,14 @@ export const usePTT = (
|
||||||
onClientSync,
|
onClientSync,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
client.on(ClientEvent.Sync, onClientSync);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
client.removeListener(ClientEvent.Sync, onClientSync);
|
||||||
|
};
|
||||||
|
}, [client, onClientSync]);
|
||||||
|
|
||||||
const setTalkOverEnabled = useCallback((talkOverEnabled) => {
|
const setTalkOverEnabled = useCallback((talkOverEnabled) => {
|
||||||
setState((prevState) => ({
|
setState((prevState) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
|
|
Loading…
Reference in a new issue