mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-26 00:50:56 -05:00
Fix voice and abnormal CPU usage.
This commit is contained in:
parent
0ea80b5717
commit
0fe154c651
1 changed files with 8 additions and 15 deletions
|
@ -65,7 +65,8 @@ export default function Voice({ children }: Props) {
|
||||||
participants: client?.participants ?? new Map(),
|
participants: client?.participants ?? new Map(),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[client?.participants, client?.roomId],
|
// eslint-disable-next-line
|
||||||
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -84,7 +85,8 @@ export default function Voice({ children }: Props) {
|
||||||
console.error("Failed to load voice library!", err);
|
console.error("Failed to load voice library!", err);
|
||||||
setStatus(VoiceStatus.UNAVAILABLE);
|
setStatus(VoiceStatus.UNAVAILABLE);
|
||||||
});
|
});
|
||||||
}, [setStatus]);
|
// eslint-disable-next-line
|
||||||
|
}, []);
|
||||||
|
|
||||||
const isConnecting = useRef(false);
|
const isConnecting = useRef(false);
|
||||||
const operations: VoiceOperations = useMemo(() => {
|
const operations: VoiceOperations = useMemo(() => {
|
||||||
|
@ -166,7 +168,8 @@ export default function Voice({ children }: Props) {
|
||||||
return client?.stopProduce(type);
|
return client?.stopProduce(type);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}, [client, setStatus]);
|
// eslint-disable-next-line
|
||||||
|
}, [client]);
|
||||||
|
|
||||||
const playSound = useContext(SoundContext);
|
const playSound = useContext(SoundContext);
|
||||||
|
|
||||||
|
@ -183,25 +186,15 @@ export default function Voice({ children }: Props) {
|
||||||
|
|
||||||
client.on("startProduce", stateUpdate);
|
client.on("startProduce", stateUpdate);
|
||||||
client.on("stopProduce", stateUpdate);
|
client.on("stopProduce", stateUpdate);
|
||||||
|
client.on("userJoined", stateUpdate);
|
||||||
client.on("userJoined", () => {
|
client.on("userLeft", stateUpdate);
|
||||||
playSound("call_join");
|
|
||||||
stateUpdate();
|
|
||||||
});
|
|
||||||
client.on("userLeft", () => {
|
|
||||||
playSound("call_leave");
|
|
||||||
stateUpdate();
|
|
||||||
});
|
|
||||||
|
|
||||||
client.on("userStartProduce", stateUpdate);
|
client.on("userStartProduce", stateUpdate);
|
||||||
client.on("userStopProduce", stateUpdate);
|
client.on("userStopProduce", stateUpdate);
|
||||||
|
|
||||||
client.on("close", stateUpdate);
|
client.on("close", stateUpdate);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
client.removeListener("startProduce", stateUpdate);
|
client.removeListener("startProduce", stateUpdate);
|
||||||
client.removeListener("stopProduce", stateUpdate);
|
client.removeListener("stopProduce", stateUpdate);
|
||||||
|
|
||||||
client.removeListener("userJoined", stateUpdate);
|
client.removeListener("userJoined", stateUpdate);
|
||||||
client.removeListener("userLeft", stateUpdate);
|
client.removeListener("userLeft", stateUpdate);
|
||||||
client.removeListener("userStartProduce", stateUpdate);
|
client.removeListener("userStartProduce", stateUpdate);
|
||||||
|
|
Loading…
Reference in a new issue