Skip to content

Commit

Permalink
[FIX] Fixing Jitsi call ended Issue. (#21808)
Browse files Browse the repository at this point in the history
Co-authored-by: Guilherme Gazzo <guilherme@gazzo.xyz>
  • Loading branch information
yash-rajpal and ggazzo authored May 21, 2021
1 parent 6ae1d28 commit 5725c8b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
5 changes: 5 additions & 0 deletions app/ui-sidenav/client/roomList.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ const mergeSubRoom = (subscription) => {
usernames: 1,
topic: 1,
encrypted: 1,
jitsiTimeout: 1,
// autoTranslate: 1,
// autoTranslateLanguage: 1,
description: 1,
Expand Down Expand Up @@ -182,6 +183,7 @@ const mergeSubRoom = (subscription) => {
teamMain,
uids,
usernames,
jitsiTimeout,

v,
transcriptRequest,
Expand Down Expand Up @@ -214,6 +216,7 @@ const mergeSubRoom = (subscription) => {
teamMain,
uids,
usernames,
jitsiTimeout,

v,
transcriptRequest,
Expand Down Expand Up @@ -251,6 +254,7 @@ const mergeRoomSub = (room) => {
teamMain,
uids,
usernames,
jitsiTimeout,

v,
transcriptRequest,
Expand Down Expand Up @@ -296,6 +300,7 @@ const mergeRoomSub = (room) => {
responseBy,
priorityId,
livechatData,
jitsiTimeout,
ts,
...getLowerCaseNames(room, sub.name, sub.fname),
},
Expand Down
17 changes: 13 additions & 4 deletions client/views/room/contextualBar/Call/Jitsi/CallJitsWithData.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { useConnectionStatus } from '../../../../../contexts/ConnectionStatusCon
import { useSetModal } from '../../../../../contexts/ModalContext';
import { useMethod } from '../../../../../contexts/ServerContext';
import { useSettings } from '../../../../../contexts/SettingsContext';
import { useUserRoom, useUser } from '../../../../../contexts/UserContext';
import { useUser } from '../../../../../contexts/UserContext';
import { useRoom } from '../../../contexts/RoomContext';
import { useTabBarClose } from '../../../providers/ToolboxProvider';
import CallJitsi from './CallJitsi';
import CallModal from './components/CallModal';
Expand All @@ -34,7 +35,7 @@ const CallJitsWithData = ({ rid }) => {
const { connected } = useConnectionStatus();
const [accessToken, setAccessToken] = useSafely(useState());
const [accepted, setAccepted] = useState(false);
const room = useUserRoom(rid);
const room = useRoom();
const setModal = useSetModal();
const handleClose = useTabBarClose();
const closeModal = useMutableCallback(() => setModal(null));
Expand Down Expand Up @@ -119,6 +120,12 @@ const CallJitsWithData = ({ rid }) => {
]);

const testAndHandleTimeout = useMutableCallback(() => {
if (jitsi.openNewWindow) {
if (jitsi.window?.closed) {
return jitsi.dispose();
}
return updateTimeout(rid);
}
if (new Date() - new Date(room.jitsiTimeout) > TIMEOUT) {
return jitsi.dispose();
}
Expand All @@ -137,11 +144,13 @@ const CallJitsWithData = ({ rid }) => {
updateTimeout(rid);

jitsi.on('HEARTBEAT', testAndHandleTimeout);

return () => {
const none = () => {};
const clear = () => {
jitsi.off('HEARTBEAT', testAndHandleTimeout);
jitsi.dispose();
};

return jitsi.openNewWindow ? none : clear;
}, [accepted, jitsi, rid, testAndHandleTimeout, updateTimeout]);

const handleYes = useMutableCallback(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class JitsiBridge extends Emitter {
this.desktopSharingChromeExtId = desktopSharingChromeExtId;
this.name = name;
this.heartbeat = heartbeat;
this.window = undefined;
}

start(domTarget) {
Expand Down Expand Up @@ -59,7 +60,7 @@ export class JitsiBridge extends Emitter {
}, 1000);

this.once('dispose', () => clearTimeout(timer));

this.window = newWindow;
return newWindow.focus();
}

Expand Down

0 comments on commit 5725c8b

Please sign in to comment.