Skip to content

Commit

Permalink
feat: added videoConference statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
pnboliveira committed Apr 4, 2024
1 parent d7f3634 commit 9188722
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/components/videoCall/VideoCall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const VideoCall = () => {
const [externalApi, setExternalApi] = useState<IJitsiMeetExternalApi>(null);
const [rejected, setRejected] = useState(false);
const [closed, setClosed] = useState(false);
const [joined, setJoined] = useState(false);
const [quitted, setQuitted] = useState(false);
const [ready, setReady] = useState(false);
const [e2eEnabled, setE2EEnabled] = useState(false);
const [videoCallJwtData, setVideoCallJwtData] =
Expand Down Expand Up @@ -93,6 +95,17 @@ const VideoCall = () => {
setClosed(true);
}, []);

const handleConferenceJoined = useCallback(() => {
setJoined(true);
}, []);

const handleConferenceLeft = useCallback(() => {
// User have to be joined before he can quit. Lobby already calls left event
if (joined) {
setQuitted(true);
}
}, [joined]);

const handleCustomE2EEToggled = useCallback((e) => {
setE2EEnabled(e.enabled);
}, []);
Expand All @@ -118,6 +131,8 @@ const VideoCall = () => {
}

externalApi.on('custom-e2ee-toggled', handleCustomE2EEToggled);
externalApi.on('videoConferenceJoined', handleConferenceJoined);
externalApi.on('videoConferenceLeft', handleConferenceLeft);
}

return () => {
Expand All @@ -128,14 +143,20 @@ const VideoCall = () => {
} else {
externalApi.off('errorOccurred', handleJitsiError);
}

externalApi.off(
'videoConferenceJoined',
handleConferenceJoined
);
externalApi.off('videoConferenceLeft', handleConferenceLeft);
externalApi.off('custom-e2ee-toggled', handleCustomE2EEToggled);
}
};
}, [
externalApi,
handleClose,
handleCustomE2EEToggled,
handleConferenceJoined,
handleConferenceLeft,
handleJitsiError,
videoCallJwtData
]);
Expand All @@ -148,6 +169,10 @@ const VideoCall = () => {
return <Loading />;
}

if (quitted) {
return <StatusPage closed={quitted} />;
}

return (
<div data-cy="jitsi-meeting">
{settings.jitsi.showE2EEBanner && (
Expand Down

0 comments on commit 9188722

Please sign in to comment.