Skip to content

Commit

Permalink
fix(recent-list) clean room names
Browse files Browse the repository at this point in the history
  • Loading branch information
saghul committed Sep 5, 2023
1 parent 4766080 commit 6261470
Showing 1 changed file with 20 additions and 4 deletions.
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 6261470

Please sign in to comment.