Skip to content

Commit

Permalink
fix: Fixes leaving the visitor's meeting on promotion. (jitsi#14239)
Browse files Browse the repository at this point in the history
* fix: Fixes leaving the visitor's meeting on promotion.

This was resulting some colibri websockets reconnects as the state of the previous JitsiConference was not cleaned up.

* squash: Update jsdocs, lint error.
  • Loading branch information
damencho authored Jan 16, 2024
1 parent 9ae5677 commit 33e38f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 1 addition & 4 deletions react/features/base/conference/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1000,8 +1000,6 @@ export function setAssumedBandwidthBps(assumedBandwidthBps: number) {
*/
export function redirect(vnode: string, focusJid: string, username: string) {
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const { conference, joining } = getState()['features/base/conference'];
const currentConference = conference || joining;
const newConfig = getVisitorOptions(getState, vnode, focusJid, username);

if (!newConfig) {
Expand All @@ -1011,8 +1009,7 @@ export function redirect(vnode: string, focusJid: string, username: string) {
}

dispatch(overwriteConfig(newConfig)) // @ts-ignore
.then(() => currentConference && dispatch(conferenceWillLeave(currentConference, true)))
.then(() => dispatch(disconnect()))
.then(() => dispatch(disconnect(true)))
.then(() => dispatch(setIAmVisitor(Boolean(vnode))))

// we do not clear local tracks on error, so we need to manually clear them
Expand Down
6 changes: 4 additions & 2 deletions react/features/base/connection/actions.any.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,11 @@ function _connectionWillConnect(connection: Object) {
/**
* Closes connection.
*
* @param {boolean} isRedirect - Indicates if the action has been dispatched as part of visitor promotion.
*
* @returns {Function}
*/
export function disconnect() {
export function disconnect(isRedirect?: boolean) {
return (dispatch: IStore['dispatch'], getState: IStore['getState']): Promise<void> => {
const state = getState();

Expand All @@ -348,7 +350,7 @@ export function disconnect() {
// (and the respective Redux action) which is fired after the
// conference has been left, notify the application about the
// intention to leave the conference.
dispatch(conferenceWillLeave(conference_));
dispatch(conferenceWillLeave(conference_, isRedirect));

promise
= conference_.leave()
Expand Down

0 comments on commit 33e38f9

Please sign in to comment.