feat(App): move participant leaving logic to base/participants

This commit is contained in:
Saúl Ibarra Corretgé 2018-07-10 11:11:45 +02:00 committed by Lyubo Marinov
parent 96a837801e
commit f2f991e969
2 changed files with 24 additions and 8 deletions

View File

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

View File

@ -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.
*