Skip to content

Commit

Permalink
Fix recent list to skip tokens (#906)
Browse files Browse the repository at this point in the history
* fix(conference) fix handling iframe load error

It can happen if DNS resolution fails, for example.

* fix(recent-list) clean room names

Fixes: #903
  • Loading branch information
saghul authored Sep 5, 2023
1 parent 8c57368 commit 624e1f8
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 5 deletions.
35 changes: 34 additions & 1 deletion app/features/conference/components/Conference.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,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.
*/
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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
});
Expand Down
24 changes: 20 additions & 4 deletions app/features/recent-list/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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.
Expand Down Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 624e1f8

Please sign in to comment.