diff options
author | Saúl Ibarra Corretgé <s@saghul.net> | 2023-09-05 23:07:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-05 23:07:09 +0200 |
commit | 624e1f897a3021f0956b8acd9e05e13e07f29a09 (patch) | |
tree | 2b09e47f30efb2fae117029a56d4e1fc0a07b463 | |
parent | 8c573688d5e01947d90bce47ce9e83821268f88f (diff) |
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
-rw-r--r-- | app/features/conference/components/Conference.js | 35 | ||||
-rw-r--r-- | 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 f10a7c2..df60e46 100644 --- a/app/features/conference/components/Conference.js +++ b/app/features/conference/components/Conference.js @@ -74,6 +74,11 @@ class Conference extends Component<Props, State> { _conference: Object; /** + * Whether the iframe was loaded or not. + */ + _iframeLoaded: boolean; + + /** * Timer to cancel the joining if it takes too long. */ _loadTimer: ?TimeoutID; @@ -159,6 +164,7 @@ class Conference extends Component<Props, State> { 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<Props, State> { ...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<Props, State> { * @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 17e86db..c78b9b2 100644 --- a/app/features/recent-list/reducer.js +++ b/app/features/recent-list/reducer.js @@ -47,6 +47,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. * * @param {Array<RecentListItem>} recentList - Previous 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<RecentListItem> = 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<RecentListItem>, 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; } } |