From dedd10c62ab0058708e58ec08b7f586f1e9c4685 Mon Sep 17 00:00:00 2001 From: paweldomas Date: Fri, 20 Oct 2017 12:53:10 -0500 Subject: [PATCH] fix(auth.native): trigger conference left on cancel Triggering the 'conference left' action when the wait for owner dialog is dismissed will let the Call Kit implementation end the call, after a recoverable conference failed event was emitted. Also fixes conference state reduction when 'conference left' is emitted by room lock or auth features where the conference has not been joined yet. --- react/features/authentication/actions.js | 10 +++++-- react/features/base/conference/reducer.js | 34 +++++++++++++++-------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/react/features/authentication/actions.js b/react/features/authentication/actions.js index 4dc7439d2..b0ec8077e 100644 --- a/react/features/authentication/actions.js +++ b/react/features/authentication/actions.js @@ -1,7 +1,7 @@ // @flow import { appNavigate } from '../app'; -import { checkIfCanJoin } from '../base/conference'; +import { checkIfCanJoin, conferenceLeft } from '../base/conference'; import { openDialog } from '../base/dialog'; import { @@ -82,8 +82,14 @@ export function cancelLogin() { * @returns {Function} */ export function cancelWaitForOwner() { - return (dispatch: Dispatch<*>) => { + return (dispatch: Dispatch<*>, getState: Function) => { dispatch(stopWaitForOwner()); + const { authRequired } = getState()['features/base/conference']; + + if (authRequired) { + dispatch(conferenceLeft(authRequired)); + } + dispatch(appNavigate(undefined)); }; } diff --git a/react/features/base/conference/reducer.js b/react/features/base/conference/reducer.js index 1d109449f..2b3bf8114 100644 --- a/react/features/base/conference/reducer.js +++ b/react/features/base/conference/reducer.js @@ -183,19 +183,31 @@ function _conferenceJoined(state, { conference }) { * reduction of the specified action. */ function _conferenceLeft(state, { conference }) { - if (state.conference !== conference) { - return state; + let output = state; + + if (state.authRequired === conference) { + output = set(output, 'authRequired', undefined); + } + if (state.conference === conference) { + output = assign(output, { + conference: undefined, + joining: undefined, + leaving: undefined + }); + } + if (state.passwordRequired === conference) { + // Note that in case the conference was joined those fields have been + // cleared already, so this step needs to be done only if the room + // unlock operation has been canceled and that's why it's not done in + // the 'state.conference' condition above. + output = assign(output, { + locked: undefined, + password: undefined, + passwordRequired: undefined + }); } - return assign(state, { - authRequired: undefined, - conference: undefined, - joining: undefined, - leaving: undefined, - locked: undefined, - password: undefined, - passwordRequired: undefined - }); + return output; } /**