Files
jitsi-meet/react/features/polls-history/reducer.ts
Дамян Минков 469406d7cd feat(polls): Move polls to using a component (#16406)
* squash: Renames module.

* squash: Loads polls component.

* squash: Attach needed logic when components/hosts load.

* squash: Moves to use component.

* squash: Uses json-message format with types.

* squash: Checks for polls support.

* squash: Fixes comments and moves validate polls to backend.

* squash: Fix debian build.

* fix(polls): Fixes polls in breakout rooms.

* squash: Further simplify types.

Separate type that needs to go into ljm and those used only for the UI part.
Simplify answer/voter type to be unified across operations which simplifies and its logic.

* squash: Change voters structure to be {id, name}.

* squash: Update react/features/conference/functions.any.ts

Co-authored-by: Saúl Ibarra Corretgé <saghul@jitsi.org>

* squash: Drops roomJid from messages. Uses the connection information as breakout does.

---------

Co-authored-by: Saúl Ibarra Corretgé <saghul@jitsi.org>
2025-09-25 16:46:06 -05:00

53 lines
1.3 KiB
TypeScript

import PersistenceRegistry from '../base/redux/PersistenceRegistry';
import ReducerRegistry from '../base/redux/ReducerRegistry';
import { IPollData } from '../polls/types';
import { REMOVE_POLL_FROM_HISTORY, SAVE_POLL_IN_HISTORY } from './actionTypes';
const INITIAL_STATE = {
polls: {}
};
export interface IPollsHistoryState {
polls: {
[meetingId: string]: {
[pollId: string]: IPollData;
};
};
}
const STORE_NAME = 'features/polls-history';
PersistenceRegistry.register(STORE_NAME, INITIAL_STATE);
ReducerRegistry.register<IPollsHistoryState>(STORE_NAME, (state = INITIAL_STATE, action): IPollsHistoryState => {
switch (action.type) {
case REMOVE_POLL_FROM_HISTORY: {
if (Object.keys(state.polls[action.meetingId] ?? {})?.length === 1) {
delete state.polls[action.meetingId];
} else {
delete state.polls[action.meetingId]?.[action.pollId];
}
return state;
}
case SAVE_POLL_IN_HISTORY: {
return {
...state,
polls: {
...state.polls,
[action.meetingId]: {
...state.polls[action.meetingId],
[action.pollId]: action.poll
}
}
};
}
default:
return state;
}
});