2023-02-08 17:48:11 +00:00
|
|
|
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']);
|
|
|
|
|
2023-02-24 17:16:58 +00:00
|
|
|
if (!isNaN(visitorCount) && getState()['features/visitors'].count !== visitorCount) {
|
2023-02-08 17:48:11 +00:00
|
|
|
dispatch(updateVisitorsCount(visitorCount));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|