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.
This commit is contained in:
paweldomas 2017-10-20 12:53:10 -05:00 committed by Lyubo Marinov
parent f1cc057bde
commit dedd10c62a
2 changed files with 31 additions and 13 deletions

View File

@ -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));
};
}

View File

@ -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;
}
/**