Skip to content
Snippets Groups Projects
Unverified Commit f9ff204e authored by Aman-Maheshwari's avatar Aman-Maheshwari Committed by GitHub
Browse files

[FIX] Jitsi call already ended (#23904)


* fix-jitsi call already ended

Co-authored-by: default avataryash-rajpal <rajpal.yash03@gmail.com>
parent 1ac269ab
No related branches found
No related tags found
No related merge requests found
......@@ -124,13 +124,13 @@ const CallJitsiWithData = ({ rid }) => {
user.username,
]);
const testAndHandleTimeout = useMutableCallback(async () => {
const testAndHandleTimeout = useMutableCallback(() => {
if (jitsi.openNewWindow) {
if (jitsi.window?.closed) {
return jitsi.dispose();
}
try {
await updateTimeout(rid, false);
return updateTimeout(rid, false);
} catch (error) {
dispatchToastMessage({ type: 'error', message: t(error.reason) });
clear();
......@@ -144,7 +144,7 @@ const CallJitsiWithData = ({ rid }) => {
if (new Date() - new Date(room.jitsiTimeout) + TIMEOUT > DEBOUNCE) {
try {
await updateTimeout(rid, false);
return updateTimeout(rid, false);
} catch (error) {
dispatchToastMessage({ type: 'error', message: t(error.reason) });
clear();
......@@ -155,41 +155,32 @@ const CallJitsiWithData = ({ rid }) => {
});
useEffect(() => {
let shouldDispose = false;
async function fetchData() {
if (!accepted || !jitsi) {
return;
}
if (!accepted || !jitsi) {
return;
}
const clear = () => {
jitsi.off('HEARTBEAT', testAndHandleTimeout);
jitsi.dispose();
};
const clear = () => {
jitsi.off('HEARTBEAT', testAndHandleTimeout);
jitsi.dispose();
};
try {
if (jitsi.needsStart) {
jitsi.start(ref.current);
await updateTimeout(rid, true);
} else {
await updateTimeout(rid, false);
}
} catch (error) {
dispatchToastMessage({ type: 'error', message: t(error.reason) });
clear();
handleClose();
try {
if (jitsi.needsStart) {
jitsi.start(ref.current);
updateTimeout(rid, true);
} else {
updateTimeout(rid, false);
}
jitsi.on('HEARTBEAT', testAndHandleTimeout);
shouldDispose = jitsi.openNewWindow;
} catch (error) {
dispatchToastMessage({ type: 'error', message: t(error.reason) });
clear();
handleClose();
}
jitsi.on('HEARTBEAT', testAndHandleTimeout);
fetchData().then(() => {
if (shouldDispose) {
jitsi.dispose();
}
});
return () => {
if (!jitsi.openNewWindow) clear();
};
}, [
accepted,
jitsi,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment