From f2f991e969211bdaa94b00251afd2e6dc63402bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Tue, 10 Jul 2018 11:11:45 +0200 Subject: [PATCH] feat(App): move participant leaving logic to base/participants --- react/features/app/components/AbstractApp.js | 9 ++------ .../features/base/participants/middleware.js | 23 ++++++++++++++++++- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/react/features/app/components/AbstractApp.js b/react/features/app/components/AbstractApp.js index 7bb48ece7..cbd5c5d69 100644 --- a/react/features/app/components/AbstractApp.js +++ b/react/features/app/components/AbstractApp.js @@ -9,7 +9,6 @@ import { compose, createStore } from 'redux'; import Thunk from 'redux-thunk'; import { i18next } from '../../base/i18n'; -import { localParticipantLeft } from '../../base/participants'; import { MiddlewareRegistry, ReducerRegistry, @@ -118,8 +117,7 @@ export class AbstractApp extends Component { } /** - * Init lib-jitsi-meet and create local participant when component is going - * to be mounted. + * Initializes the app. * * @inheritdoc */ @@ -185,16 +183,13 @@ export class AbstractApp extends Component { } /** - * Dispose lib-jitsi-meet and remove local participant when component is - * going to be unmounted. + * De-initializes the app. * * @inheritdoc */ componentWillUnmount() { const { dispatch } = this._getStore(); - dispatch(localParticipantLeft()); - dispatch(appWillUnmount(this)); } diff --git a/react/features/base/participants/middleware.js b/react/features/base/participants/middleware.js index a2549f132..bfacded26 100644 --- a/react/features/base/participants/middleware.js +++ b/react/features/base/participants/middleware.js @@ -14,6 +14,7 @@ import { playSound, registerSound, unregisterSound } from '../sounds'; import { localParticipantIdChanged, localParticipantJoined, + localParticipantLeft, participantLeft, participantUpdated } from './actions'; @@ -57,7 +58,8 @@ MiddlewareRegistry.register(store => next => action => { case APP_WILL_UNMOUNT: _unregisterSounds(store); - break; + + return _localParticipantLeft(store, next, action); case CONFERENCE_WILL_JOIN: store.dispatch(localParticipantIdChanged(action.conference.myUserId())); @@ -202,6 +204,25 @@ function _localParticipantJoined({ getState, dispatch }, next, action) { return result; } +/** + * Signals that the local participant has left. + * + * @param {Store} store - The redux store. + * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the + * specified {@code action} into the specified {@code store}. + * @param {Action} action - The redux action which is being dispatched in the + * specified {@code store}. + * @private + * @returns {Object} The value returned by {@code next(action)}. + */ +function _localParticipantLeft({ dispatch }, next, action) { + const result = next(action); + + dispatch(localParticipantLeft()); + + return result; +} + /** * Plays sounds when participants join/leave conference. *