Files
upstream-jitsi-meet/react/features/polls-history/middleware.ts
upstream-mirror 1d2bfcac0c
Some checks failed
Prosody Plugin Tests / test (push) Failing after 10m11s
Close stale issues and PRs / stale (push) Failing after 1s
snapshot of https://github.com/jitsi/jitsi-meet.git @ fd1749dd28f4138aa80234fc7f311b19aaffa0e7 (2026-09-15)
2026-09-15 15:56:32 +05:00

47 lines
1.3 KiB
TypeScript

import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { REMOVE_POLL, SAVE_POLL } from '../polls/actionTypes';
import { savePoll } from '../polls/actions';
import { removePollFromHistory, savePollInHistory } from './actions';
MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
const result = next(action);
const { room: meetingId } = getState()['features/base/conference'];
switch (action.type) {
case CONFERENCE_JOINED: {
const state = getState();
const pollsHistory = meetingId && state['features/polls-history'].polls?.[meetingId];
if (!pollsHistory) {
return null;
}
for (const key in pollsHistory) {
if (pollsHistory.hasOwnProperty(key) && pollsHistory[key].saved) {
dispatch(savePoll(pollsHistory[key]));
}
}
break;
}
case REMOVE_POLL: {
const { poll, pollId } = action;
dispatch(removePollFromHistory(meetingId, pollId, poll));
break;
}
case SAVE_POLL: {
const { poll, pollId } = action;
dispatch(savePollInHistory(meetingId, pollId, poll));
break;
}
}
return result;
});