From 251b42ca5464d6edc3b6a610d751cfe4159408a4 Mon Sep 17 00:00:00 2001 From: Alex Junior Date: Tue, 16 Nov 2021 13:04:33 -0300 Subject: [PATCH] [IMPROVE] Open Jitsi call even if server isn't found (#3442) --- app/index.tsx | 4 +++- app/lib/methods/callJitsi.js | 8 ++++++++ app/lib/rocketchat.js | 3 ++- app/sagas/deepLinking.js | 5 +++++ app/views/JitsiMeetView.js | 18 ++++++++++-------- 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/app/index.tsx b/app/index.tsx index 31128db26..e6457e233 100644 --- a/app/index.tsx +++ b/app/index.tsx @@ -63,10 +63,12 @@ const parseDeepLinking = (url: string) => { } } const call = /^(https:\/\/)?jitsi.rocket.chat\//; + const fullURL = url; + if (url.match(call)) { url = url.replace(call, '').trim(); if (url) { - return { path: url, isCall: true }; + return { path: url, isCall: true, fullURL }; } } } diff --git a/app/lib/methods/callJitsi.js b/app/lib/methods/callJitsi.js index 19263f135..8d2fa7db4 100644 --- a/app/lib/methods/callJitsi.js +++ b/app/lib/methods/callJitsi.js @@ -36,6 +36,14 @@ async function jitsiURL({ room }) { return `${protocol}${domain}${prefix}${rname}${queryString}`; } +export function callJitsiWithoutServer(path) { + logEvent(events.RA_JITSI_VIDEO); + const { Jitsi_SSL } = reduxStore.getState().settings; + const protocol = Jitsi_SSL ? 'https://' : 'http://'; + const url = `${protocol}${path}`; + Navigation.navigate('JitsiMeetView', { url, onlyAudio: false }); +} + async function callJitsi(room, onlyAudio = false) { logEvent(onlyAudio ? events.RA_JITSI_AUDIO : events.RA_JITSI_VIDEO); const url = await jitsiURL.call(this, { room }); diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index 2862b1d90..fac6d2c1f 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -54,7 +54,7 @@ import loadMissedMessages from './methods/loadMissedMessages'; import loadThreadMessages from './methods/loadThreadMessages'; import sendMessage, { resendMessage } from './methods/sendMessage'; import { cancelUpload, isUploadActive, sendFileMessage } from './methods/sendFileMessage'; -import callJitsi from './methods/callJitsi'; +import callJitsi, { callJitsiWithoutServer } from './methods/callJitsi'; import logout, { removeServer } from './methods/logout'; import UserPreferences from './userPreferences'; import { Encryption } from './encryption'; @@ -76,6 +76,7 @@ const RocketChat = { CURRENT_SERVER, CERTIFICATE_KEY, callJitsi, + callJitsiWithoutServer, async subscribeRooms() { if (!this.roomsSub) { try { diff --git a/app/sagas/deepLinking.js b/app/sagas/deepLinking.js index 101747ccd..240771b3e 100644 --- a/app/sagas/deepLinking.js +++ b/app/sagas/deepLinking.js @@ -122,6 +122,11 @@ const handleOpen = function* handleOpen({ params }) { host = id; } }); + + if (!host && params.fullURL) { + RocketChat.callJitsiWithoutServer(params.fullURL); + return; + } } if (params.type === 'oauth') { diff --git a/app/views/JitsiMeetView.js b/app/views/JitsiMeetView.js index e80cdae85..06b753631 100644 --- a/app/views/JitsiMeetView.js +++ b/app/views/JitsiMeetView.js @@ -81,15 +81,17 @@ class JitsiMeetView extends React.Component { // call is not ended and is available to web users. onConferenceJoined = () => { logEvent(events.JM_CONFERENCE_JOIN); - RocketChat.updateJitsiTimeout(this.rid).catch(e => console.log(e)); - if (this.jitsiTimeout) { - BackgroundTimer.clearInterval(this.jitsiTimeout); - BackgroundTimer.stopBackgroundTimer(); - this.jitsiTimeout = null; - } - this.jitsiTimeout = BackgroundTimer.setInterval(() => { + if (this.rid) { RocketChat.updateJitsiTimeout(this.rid).catch(e => console.log(e)); - }, 10000); + if (this.jitsiTimeout) { + BackgroundTimer.clearInterval(this.jitsiTimeout); + BackgroundTimer.stopBackgroundTimer(); + this.jitsiTimeout = null; + } + this.jitsiTimeout = BackgroundTimer.setInterval(() => { + RocketChat.updateJitsiTimeout(this.rid).catch(e => console.log(e)); + }, 10000); + } }; onConferenceTerminated = () => {