mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-14 15:17:50 +00:00
44 lines
1.0 KiB
JavaScript
44 lines
1.0 KiB
JavaScript
/* @flow */
|
|
import { PROFILE_UPDATED } from './actionTypes';
|
|
import MiddlewareRegistry from '../redux/MiddlewareRegistry';
|
|
|
|
import { participantUpdated } from '../participants';
|
|
import { getProfile } from '../profile';
|
|
import { toState } from '../redux';
|
|
|
|
/**
|
|
* A MiddleWare to update the local participant when the profile
|
|
* is updated.
|
|
*
|
|
* @param {Store} store - The redux store.
|
|
* @returns {Function}
|
|
*/
|
|
MiddlewareRegistry.register(store => next => action => {
|
|
const result = next(action);
|
|
|
|
switch (action.type) {
|
|
case PROFILE_UPDATED:
|
|
_updateLocalParticipant(store);
|
|
}
|
|
|
|
return result;
|
|
});
|
|
|
|
/**
|
|
* Updates the local participant according to profile changes.
|
|
*
|
|
* @param {Store} store - The redux store.
|
|
* @returns {void}
|
|
*/
|
|
function _updateLocalParticipant(store) {
|
|
const profile = getProfile(toState(store));
|
|
|
|
const newLocalParticipant = {
|
|
email: profile.email,
|
|
local: true,
|
|
name: profile.displayName
|
|
};
|
|
|
|
store.dispatch(participantUpdated(newLocalParticipant));
|
|
}
|