[RN] CONFERENCE_LEFT upon canceling PasswordRequiredPrompt

This commit is contained in:
Lyubo Marinov 2017-10-17 17:06:41 -05:00
parent 9135f654ba
commit a561d4f302
2 changed files with 45 additions and 6 deletions

View File

@ -1,6 +1,11 @@
// @flow
import { setPassword } from '../base/conference';
import { appNavigate } from '../app';
import {
conferenceLeft,
JITSI_CONFERENCE_URL_KEY,
setPassword
} from '../base/conference';
import { hideDialog, openDialog } from '../base/dialog';
import { PasswordRequiredPrompt, RoomLockPrompt } from './components';
@ -23,6 +28,38 @@ export function beginRoomLockRequest(conference: ?Object) {
};
}
/**
* Cancels a prompt for a password to join a specific conference/room.
*
* @param {JitsiConference} conference - The {@code JitsiConference} requesting
* the password to join.
* @protected
* @returns {Function}
*/
export function _cancelPasswordRequiredPrompt(conference: Object) {
return (dispatch: Dispatch<*>, getState: Function) => {
// Canceling PasswordRequiredPrompt is to navigate the app/user to
// WelcomePage. In other words, the canceling invalidates the
// locationURL. Make sure that the canceling indeed has the intent to
// invalidate the locationURL.
const state = getState();
if (conference === state['features/base/conference'].passwordRequired
&& conference[JITSI_CONFERENCE_URL_KEY]
=== state['features/base/connection'].locationURL) {
// XXX The error associated with CONFERENCE_FAILED was marked as
// recoverable by the feature room-lock and, consequently,
// recoverable-aware features such as mobile's external-api did not
// deliver the CONFERENCE_FAILED to the SDK clients/consumers. Since
// the app/user is going to nativate to WelcomePage, the SDK
// clients/consumers need an event.
dispatch(conferenceLeft(conference));
dispatch(appNavigate(undefined));
}
};
}
/**
* Ends a (user) request to lock a specific conference/room.
*
@ -47,10 +84,10 @@ export function endRoomLockRequest(
}
/**
* Begins a request to enter password for a specific conference/room.
* Begins a prompt for a password to join a specific conference/room.
*
* @param {JitsiConference} conference - The JitsiConference
* requesting password.
* @param {JitsiConference} conference - The {@code JitsiConference}
* requesting the password to join.
* @protected
* @returns {{
* type: OPEN_DIALOG,

View File

@ -4,10 +4,11 @@ import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { appNavigate } from '../../app';
import { setPassword } from '../../base/conference';
import { Dialog } from '../../base/dialog';
import { _cancelPasswordRequiredPrompt } from '../actions';
/**
* {@code PasswordRequiredPrompt}'s React {@code Component} prop types.
*/
@ -87,7 +88,8 @@ class PasswordRequiredPrompt extends Component {
* otherwise, {@code false}.
*/
_onCancel() {
this.props.dispatch(appNavigate(undefined));
this.props.dispatch(
_cancelPasswordRequiredPrompt(this.props.conference));
return true;
}