feat(overlay): Clear redux state on CONNECTION_WILL_CONNECT

This commit is contained in:
paweldomas 2017-09-19 14:20:29 -05:00 committed by Lyubo Marinov
parent 04a1da2cea
commit 9621ba03f3
1 changed files with 49 additions and 21 deletions

View File

@ -1,5 +1,9 @@
import { CONFERENCE_FAILED } from '../base/conference'; import { CONFERENCE_FAILED } from '../base/conference';
import { CONNECTION_ESTABLISHED, CONNECTION_FAILED } from '../base/connection'; import {
CONNECTION_ESTABLISHED,
CONNECTION_FAILED,
CONNECTION_WILL_CONNECT
} from '../base/connection';
import { import {
isFatalJitsiConnectionError, isFatalJitsiConnectionError,
JitsiConferenceErrors, JitsiConferenceErrors,
@ -15,7 +19,7 @@ import {
const logger = require('jitsi-meet-logger').getLogger(__filename); const logger = require('jitsi-meet-logger').getLogger(__filename);
/** /**
* Reduces the Redux actions of the feature overlay. * Reduces the redux actions of the feature overlay.
*/ */
ReducerRegistry.register('features/overlay', (state = {}, action) => { ReducerRegistry.register('features/overlay', (state = {}, action) => {
switch (action.type) { switch (action.type) {
@ -28,6 +32,9 @@ ReducerRegistry.register('features/overlay', (state = {}, action) => {
case CONNECTION_FAILED: case CONNECTION_FAILED:
return _connectionFailed(state, action); return _connectionFailed(state, action);
case CONNECTION_WILL_CONNECT:
return _connectionWillConnect(state, action);
case MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED: case MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED:
return _mediaPermissionPromptVisibilityChanged(state, action); return _mediaPermissionPromptVisibilityChanged(state, action);
@ -39,13 +46,13 @@ ReducerRegistry.register('features/overlay', (state = {}, action) => {
}); });
/** /**
* Reduces a specific Redux action CONFERENCE_FAILED of the feature overlay. * Reduces a specific redux action CONFERENCE_FAILED of the feature overlay.
* *
* @param {Object} state - The Redux state of the feature overlay. * @param {Object} state - The redux state of the feature overlay.
* @param {Action} action - The Redux action CONFERENCE_FAILED to reduce. * @param {Action} action - The redux action CONFERENCE_FAILED to reduce.
* @private
* @returns {Object} The new state of the feature overlay after the reduction of * @returns {Object} The new state of the feature overlay after the reduction of
* the specified action. * the specified action.
* @private
*/ */
function _conferenceFailed(state, { error, message }) { function _conferenceFailed(state, { error, message }) {
if (error === JitsiConferenceErrors.FOCUS_LEFT if (error === JitsiConferenceErrors.FOCUS_LEFT
@ -61,30 +68,30 @@ function _conferenceFailed(state, { error, message }) {
} }
/** /**
* Reduces a specific Redux action CONNECTION_ESTABLISHED of the feature * Reduces a specific redux action CONNECTION_ESTABLISHED of the feature
* overlay. * overlay.
* *
* @param {Object} state - The Redux state of the feature overlay. * @param {Object} state - The redux state of the feature overlay.
* @private
* @returns {Object} The new state of the feature overlay after the reduction of * @returns {Object} The new state of the feature overlay after the reduction of
* the specified action. * the specified action.
* @private
*/ */
function _connectionEstablished(state) { function _connectionEstablished(state) {
return set(state, 'connectionEstablished', true); return set(state, 'connectionEstablished', true);
} }
/** /**
* Reduces a specific Redux action CONNECTION_FAILED of the feature overlay. * Reduces a specific redux action CONNECTION_FAILED of the feature overlay.
* *
* @param {Object} state - The Redux state of the feature overlay. * @param {Object} state - The redux state of the feature overlay.
* @param {Action} action - The Redux action CONNECTION_FAILED to reduce. * @param {Action} action - The redux action CONNECTION_FAILED to reduce.
* @private
* @returns {Object} The new state of the feature overlay after the reduction of * @returns {Object} The new state of the feature overlay after the reduction of
* the specified action. * the specified action.
* @private
*/ */
function _connectionFailed(state, { error, message }) { function _connectionFailed(state, { error, message }) {
if (isFatalJitsiConnectionError(error)) { if (isFatalJitsiConnectionError(error)) {
logger.error(`XMPP connection error: ${message}`); logger.error(`FATAL XMPP connection error: ${message}`);
return assign(state, { return assign(state, {
haveToReload: true, haveToReload: true,
@ -101,14 +108,35 @@ function _connectionFailed(state, { error, message }) {
} }
/** /**
* Reduces a specific Redux action MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED of * Reduces a specific redux action CONNECTION_WILL_CONNECT in the feature
* overlay. Clears the redux state related to the XMPP connection's status.
*
* @param {Object} state - The redux state of the feature overlay.
* @param {Action} action - The redux action to reduce.
* @private
* @returns {Object} The new state of the feature overlay after reducing the
* specified <tt>action</tt> in the feature overlay.
*/
function _connectionWillConnect(
state,
action) { // eslint-disable-line no-unused-vars
return assign(state, {
connectionEstablished: undefined,
haveToReload: undefined,
isNetworkFailure: undefined,
reason: undefined
});
}
/**
* Reduces a specific redux action MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED of
* the feature overlay. * the feature overlay.
* *
* @param {Object} state - The Redux state of the feature overlay. * @param {Object} state - The redux state of the feature overlay.
* @param {Action} action - The Redux action to reduce. * @param {Action} action - The redux action to reduce.
* @private
* @returns {Object} The new state of the feature overlay after the reduction of * @returns {Object} The new state of the feature overlay after the reduction of
* the specified action. * the specified action.
* @private
*/ */
function _mediaPermissionPromptVisibilityChanged(state, action) { function _mediaPermissionPromptVisibilityChanged(state, action) {
return assign(state, { return assign(state, {
@ -118,12 +146,12 @@ function _mediaPermissionPromptVisibilityChanged(state, action) {
} }
/** /**
* Reduces a specific Redux action SUSPEND_DETECTED of the feature overlay. * Reduces a specific redux action SUSPEND_DETECTED of the feature overlay.
* *
* @param {Object} state - The Redux state of the feature overlay. * @param {Object} state - The redux state of the feature overlay.
* @private
* @returns {Object} The new state of the feature overlay after the reduction of * @returns {Object} The new state of the feature overlay after the reduction of
* the specified action. * the specified action.
* @private
*/ */
function _suspendDetected(state) { function _suspendDetected(state) {
return set(state, 'suspendDetected', true); return set(state, 'suspendDetected', true);