Call the same leave method everywhere

So we end the group call span whenever we leasve the call, including
if we close the page.
This commit is contained in:
David Baker 2023-03-30 13:03:58 +01:00
parent f96ce8985d
commit 21458c8840

View file

@ -202,6 +202,11 @@ export function useGroupCall(
[]
);
const leaveCall = useCallback(() => {
groupCallOTelMembership?.onLeaveCall();
groupCall.leave();
}, [groupCall]);
useEffect(() => {
// disable the media action keys, otherwise audio elements get paused when
// the user presses media keys or unplugs headphones, etc.
@ -394,12 +399,12 @@ export function useGroupCall(
onParticipantsChanged
);
groupCall.removeListener(GroupCallEvent.Error, onError);
groupCall.leave();
leaveCall();
};
}, [groupCall, updateState]);
}, [groupCall, updateState, leaveCall]);
usePageUnload(() => {
groupCall.leave();
leaveCall();
});
const initLocalCallFeed = useCallback(
@ -426,11 +431,6 @@ export function useGroupCall(
groupCallOTelMembership?.onJoinCall();
}, [groupCall, updateState]);
const leave = useCallback(() => {
groupCallOTelMembership?.onLeaveCall();
groupCall.leave();
}, [groupCall]);
const toggleLocalVideoMuted = useCallback(() => {
const toggleToMute = !groupCall.isLocalVideoMuted();
groupCall.setLocalVideoMuted(toggleToMute);
@ -563,7 +563,7 @@ export function useGroupCall(
error,
initLocalCallFeed,
enter,
leave,
leave: leaveCall,
toggleLocalVideoMuted,
toggleMicrophoneMuted,
toggleScreensharing,