mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-09 17:12:47 +00:00
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import { CONFERENCE_JOINED, CONFERENCE_JOIN_IN_PROGRESS } from '../base/conference/actionTypes';
|
|
import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';
|
|
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
|
|
import { showNotification } from '../notifications/actions';
|
|
import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
|
|
|
|
import { updateVisitorsCount } from './actions';
|
|
|
|
MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
|
|
switch (action.type) {
|
|
case CONFERENCE_JOIN_IN_PROGRESS: {
|
|
const { conference } = action;
|
|
|
|
conference.on(JitsiConferenceEvents.PROPERTIES_CHANGED, (properties: { 'visitor-count': number; }) => {
|
|
const visitorCount = Number(properties?.['visitor-count']);
|
|
|
|
if (!isNaN(visitorCount) && getState()['features/visitors'].count !== visitorCount) {
|
|
dispatch(updateVisitorsCount(visitorCount));
|
|
}
|
|
});
|
|
break;
|
|
}
|
|
case CONFERENCE_JOINED: {
|
|
if (getState()['features/visitors'].iAmVisitor) {
|
|
dispatch(showNotification({
|
|
titleKey: 'visitors.notification.title',
|
|
descriptionKey: 'visitors.notification.description'
|
|
}, NOTIFICATION_TIMEOUT_TYPE.STICKY));
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
return next(action);
|
|
});
|