jiti-meet/react/features/visitors/middleware.ts

20 lines
783 B
TypeScript
Raw Normal View History

import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';
import StateListenerRegistry from '../base/redux/StateListenerRegistry';
import { updateVisitorsCount } from './actions';
StateListenerRegistry.register(
state => state['features/base/conference'].conference,
(conference, { dispatch, getState }, previousConference) => {
if (conference && !previousConference) {
conference.on(JitsiConferenceEvents.PROPERTIES_CHANGED, (properties: { 'visitor-count': number; }) => {
const visitorCount = Number(properties?.['visitor-count']);
if (getState()['features/visitors'].count !== visitorCount) {
dispatch(updateVisitorsCount(visitorCount));
}
});
}
});