From 624e1f897a3021f0956b8acd9e05e13e07f29a09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Tue, 5 Sep 2023 23:07:09 +0200 Subject: [PATCH] Fix recent list to skip tokens (#906) * fix(conference) fix handling iframe load error It can happen if DNS resolution fails, for example. * fix(recent-list) clean room names Fixes: https://github.com/jitsi/jitsi-meet-electron/issues/903 --- .../conference/components/Conference.js | 35 ++++++++++++++++++- app/features/recent-list/reducer.js | 24 ++++++++++--- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/app/features/conference/components/Conference.js b/app/features/conference/components/Conference.js index f10a7c212..df60e4681 100644 --- a/app/features/conference/components/Conference.js +++ b/app/features/conference/components/Conference.js @@ -73,6 +73,11 @@ class Conference extends Component { */ _conference: Object; + /** + * Whether the iframe was loaded or not. + */ + _iframeLoaded: boolean; + /** * Timer to cancel the joining if it takes too long. */ @@ -159,6 +164,7 @@ class Conference extends Component { if (prevProps.location.key !== this.props.location.key) { // Simulate a re-mount so the new meeting is joined. + this._iframeLoaded = false; this.componentWillUnmount(); this.componentDidMount(); } @@ -235,7 +241,6 @@ class Conference extends Component { ...urlParameters }); - this._api.on('suspendDetected', this._onVideoConferenceEnded); this._api.on('readyToClose', this._onVideoConferenceEnded); this._api.on('videoConferenceJoined', @@ -304,11 +309,39 @@ class Conference extends Component { * @returns {void} */ _onIframeLoad() { + if (this._iframeLoaded) { + // Skip spurious event after meeting close. + return; + } + + console.log('IFrame loaded'); + + this._iframeLoaded = true; + if (this._loadTimer) { clearTimeout(this._loadTimer); this._loadTimer = null; } + const frame = this._api.getIFrame(); + const mainApp = frame.contentWindow.document.getElementById('react'); + + if (!mainApp) { + console.warn('Main application not loaded'); + + this._navigateToHome( + + // $FlowFixMe + { + error: 'Loading error', + type: 'error' + }, + this._conference.room, + this._conference.serverURL); + + return; + } + this.setState({ isLoading: false }); diff --git a/app/features/recent-list/reducer.js b/app/features/recent-list/reducer.js index 17e86db49..c78b9b2fb 100644 --- a/app/features/recent-list/reducer.js +++ b/app/features/recent-list/reducer.js @@ -46,6 +46,19 @@ export default (state: State = DEFAULT_STATE, action: Object) => { } }; +/** + * Cleans a room name of all parameters. + * + * @param {string} roomName - The room name to be cleaned. + * @returns {string} - The cleaned up room name. + */ +function _cleanRoomName(roomName: string) { + const [ noQuery ] = roomName.split('?', 2); + const [ noParams ] = noQuery.split('#', 2); + + return noParams; +} + /** * Insert Conference details in the recent list array. * @@ -61,9 +74,11 @@ function _insertConference( // Add start time to conference. newConference.startTime = Date.now(); + newConference.room = _cleanRoomName(newConference.room); + // Remove same conference. const newRecentList: Array = recentList.filter( - (conference: RecentListItem) => conference.room !== newConference.room + (conference: RecentListItem) => _cleanRoomName(conference.room) !== newConference.room || conference.serverURL !== newConference.serverURL); // Add the conference at the beginning. @@ -99,11 +114,12 @@ function _updateEndtimeOfConference( recentList: Array, conference: RecentListItem ) { - for (const item of recentList) { - if (item.room === conference.room + for (const item of recentList.slice()) { + item.room = _cleanRoomName(item.room); + + if (item.room === _cleanRoomName(conference.room) && item.serverURL === conference.serverURL) { item.endTime = Date.now(); - break; } }