2019-06-23 14:44:22 +00:00
|
|
|
// @flow
|
|
|
|
|
2019-06-23 15:44:13 +00:00
|
|
|
import { getLocalParticipant } from '../base/participants';
|
2019-06-23 14:44:22 +00:00
|
|
|
import { StateListenerRegistry } from '../base/redux';
|
2019-06-23 15:44:13 +00:00
|
|
|
import { appendSuffix } from '../display-name';
|
2019-06-23 14:44:22 +00:00
|
|
|
import { shouldDisplayTileView } from '../video-layout';
|
|
|
|
|
|
|
|
declare var APP: Object;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* StateListenerRegistry provides a reliable way of detecting changes to
|
|
|
|
* preferred layout state and dispatching additional actions.
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
/* selector */ state => shouldDisplayTileView(state),
|
|
|
|
/* listener */ displayTileView => {
|
|
|
|
APP.API.notifyTileViewChanged(displayTileView);
|
|
|
|
});
|
2019-06-23 15:44:13 +00:00
|
|
|
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
/* selector */ state => state['features/base/settings'].displayName,
|
|
|
|
/* listener */ (displayName, store) => {
|
|
|
|
const localParticipant = getLocalParticipant(store.getState());
|
2021-11-26 15:39:34 +00:00
|
|
|
const { defaultLocalDisplayName } = store.getState()['features/base/config'];
|
2019-06-23 15:44:13 +00:00
|
|
|
|
|
|
|
// Initial setting of the display name occurs happens on app
|
|
|
|
// initialization, before the local participant is ready. The initial
|
|
|
|
// settings is not desired to be fired anyways, only changes.
|
|
|
|
if (localParticipant) {
|
|
|
|
const { id } = localParticipant;
|
|
|
|
|
|
|
|
APP.API.notifyDisplayNameChanged(id, {
|
|
|
|
displayName,
|
|
|
|
formattedDisplayName: appendSuffix(
|
|
|
|
displayName,
|
2021-11-26 15:39:34 +00:00
|
|
|
defaultLocalDisplayName
|
|
|
|
)
|
2019-06-23 15:44:13 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2020-04-14 22:41:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the on stage participant value.
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
/* selector */ state => state['features/large-video'].participantId,
|
2021-07-15 22:13:46 +00:00
|
|
|
/* listener */ participantId => {
|
|
|
|
APP.API.notifyOnStageParticipantChanged(participantId);
|
2020-04-14 22:41:30 +00:00
|
|
|
}
|
|
|
|
);
|