mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-18 06:57:56 +00:00
* fix: Fixes wrong warning message. * fix: Detect enables/disables visitors for a room. * fix: We need customusername in all cases of auto-allow setting. * feat: Sends promotion-request to all moderators. * feat(visitors): Implements request promotion. * feat(visitors): Implements single moderator and vpass cases for moderators. * fix: Fixes clearing request instances from UI. * feat: Implements visitors approval for mobile. * squash: Drops unused and wrong report for auto allow promotion. * squash: Returns early based on count. * squash: Moves translation to common key. * squash: Adds dependencies for useCallback. * squash: comments. * squash: Refactor 1 to unify with native. * squash: Rename some styles. * squash: Fixes error dew to fewer hooks error. * squash: Renames VISITOR_PROMOTION_REQUEST_DENIED. * squash: Fix renaming component. * squash: Suggestions.
69 lines
2.5 KiB
TypeScript
69 lines
2.5 KiB
TypeScript
import { CONFERENCE_JOINED, CONFERENCE_JOIN_IN_PROGRESS } from '../base/conference/actionTypes';
|
|
import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';
|
|
import { raiseHand } from '../base/participants/actions';
|
|
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
|
|
import { showNotification } from '../notifications/actions';
|
|
import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
|
|
|
|
import { clearPromotionRequest, promotionRequestReceived, updateVisitorsCount } from './actions';
|
|
import { getPromotionRequests } from './functions';
|
|
|
|
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: {
|
|
const { conference } = action;
|
|
|
|
if (getState()['features/visitors'].iAmVisitor) {
|
|
dispatch(showNotification({
|
|
titleKey: 'visitors.notification.title',
|
|
descriptionKey: 'visitors.notification.description'
|
|
}, NOTIFICATION_TIMEOUT_TYPE.STICKY));
|
|
}
|
|
|
|
conference.on(JitsiConferenceEvents.VISITORS_MESSAGE, (
|
|
msg: { from: string; nick: string; on: boolean; }) => {
|
|
const request = {
|
|
from: msg.from,
|
|
nick: msg.nick
|
|
};
|
|
|
|
if (msg.on) {
|
|
dispatch(promotionRequestReceived(request));
|
|
} else {
|
|
dispatch(clearPromotionRequest(request));
|
|
}
|
|
});
|
|
|
|
conference.on(JitsiConferenceEvents.VISITORS_REJECTION, () => {
|
|
dispatch(raiseHand(false));
|
|
});
|
|
|
|
conference.on(JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
|
|
(user: any, data: any) => {
|
|
if (data?.action === 'promotion-response' && data.approved) {
|
|
const request = getPromotionRequests(getState())
|
|
.find(r => r.from === data.id);
|
|
|
|
request && dispatch(clearPromotionRequest(request));
|
|
}
|
|
});
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
return next(action);
|
|
});
|