Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
jitsi-meet/react/features/base/profile/middleware.js

43 lines
1.0 KiB

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