From c98e7a204cb91925a7ca960766fd28496a59daf0 Mon Sep 17 00:00:00 2001 From: Lyubo Marinov Date: Thu, 5 Oct 2017 07:41:35 -0500 Subject: [PATCH] CONFERENCE_FAILED error as object --- react/features/authentication/middleware.js | 3 ++- react/features/base/conference/actionTypes.js | 2 +- react/features/base/conference/actions.js | 9 +++++++-- react/features/base/conference/reducer.js | 2 +- react/features/overlay/reducer.js | 14 +++++++++++--- react/features/room-lock/middleware.js | 3 ++- 6 files changed, 24 insertions(+), 9 deletions(-) diff --git a/react/features/authentication/middleware.js b/react/features/authentication/middleware.js index b9305d1de..f0012a73f 100644 --- a/react/features/authentication/middleware.js +++ b/react/features/authentication/middleware.js @@ -75,7 +75,8 @@ MiddlewareRegistry.register(store => next => action => { } case CONFERENCE_FAILED: - if (action.error === JitsiConferenceErrors.AUTHENTICATION_REQUIRED) { + if (action.error.name + === JitsiConferenceErrors.AUTHENTICATION_REQUIRED) { store.dispatch(waitForOwner()); } else { store.dispatch(stopWaitForOwner()); diff --git a/react/features/base/conference/actionTypes.js b/react/features/base/conference/actionTypes.js index f1336be30..9688a5a71 100644 --- a/react/features/base/conference/actionTypes.js +++ b/react/features/base/conference/actionTypes.js @@ -4,7 +4,7 @@ * { * type: CONFERENCE_FAILED, * conference: JitsiConference, - * error: string + * error: Error * } */ export const CONFERENCE_FAILED = Symbol('CONFERENCE_FAILED'); diff --git a/react/features/base/conference/actions.js b/react/features/base/conference/actions.js index 77c7b04a0..6b64d5f6e 100644 --- a/react/features/base/conference/actions.js +++ b/react/features/base/conference/actions.js @@ -159,7 +159,7 @@ function _setLocalParticipantData(conference, state) { * @returns {{ * type: CONFERENCE_FAILED, * conference: JitsiConference, - * error: string + * error: Error * }} * @public */ @@ -167,7 +167,12 @@ export function conferenceFailed(conference: Object, error: string) { return { type: CONFERENCE_FAILED, conference, - error + + // Make the error resemble an Error instance (to the extent that + // jitsi-meet needs it). + error: { + name: error + } }; } diff --git a/react/features/base/conference/reducer.js b/react/features/base/conference/reducer.js index 51983411b..1d109449f 100644 --- a/react/features/base/conference/reducer.js +++ b/react/features/base/conference/reducer.js @@ -89,7 +89,7 @@ function _conferenceFailed(state, { conference, error }) { let authRequired; let passwordRequired; - switch (error) { + switch (error.name) { case JitsiConferenceErrors.AUTHENTICATION_REQUIRED: authRequired = conference; break; diff --git a/react/features/overlay/reducer.js b/react/features/overlay/reducer.js index 27942dcea..d9832655c 100644 --- a/react/features/overlay/reducer.js +++ b/react/features/overlay/reducer.js @@ -56,12 +56,20 @@ ReducerRegistry.register('features/overlay', (state = {}, action) => { * @returns {Object} The new state of the feature overlay after the reduction of * the specified action. */ -function _conferenceFailed(state, { error, message }) { - if (error === JitsiConferenceErrors.FOCUS_LEFT - || error === JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE) { +function _conferenceFailed(state, { error: { message, name } }) { + if (name === JitsiConferenceErrors.FOCUS_LEFT + || name === JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE) { return assign(state, { haveToReload: true, isNetworkFailure: false, + + // FIXME There is no message associated with CONFERENCE_FAILED at + // the time of this writing. In jitsi-meet the action creator + // conferenceFailed neither accepts an argument message nor defines + // a property message on the error. In lib-jitsi-meet + // CONFERENCE_FAILED emissions mostly do not provide a message with + // the exception of at least one which provides an Error, not a + // string. reason: message }); } diff --git a/react/features/room-lock/middleware.js b/react/features/room-lock/middleware.js index 85a50ae45..9158e2f3e 100644 --- a/react/features/room-lock/middleware.js +++ b/react/features/room-lock/middleware.js @@ -27,7 +27,8 @@ MiddlewareRegistry.register(store => next => action => { case CONFERENCE_FAILED: { const { conference, error } = action; - if (conference && error === JitsiConferenceErrors.PASSWORD_REQUIRED) { + if (conference + && error.name === JitsiConferenceErrors.PASSWORD_REQUIRED) { store.dispatch(_openPasswordRequiredPrompt(conference)); } break;