fix(breakout-rooms): Fix polls usage.

This commit is contained in:
Дамян Минков 2021-12-17 12:58:44 -06:00
parent 11bbedf9ac
commit 32aa40b396
5 changed files with 34 additions and 1 deletions

View File

@ -124,4 +124,5 @@ Component "lobby.jitmeet.example.com" "muc"
muc_room_default_public_jids = true
modules_enabled = {
"muc_rate_limit";
"polls";
}

View File

@ -10,6 +10,15 @@
*/
export const CHANGE_VOTE = 'CHANGE_VOTE';
/**
* The type of the action which signals that we need to clear all polls from the state.
* For example we are moving to another conference.
*
* {
* type: CLEAR_POLLS
* }
*/
export const CLEAR_POLLS = 'CLEAR_POLLS';
/**
* The type of the action which signals that a new Poll was received.

View File

@ -2,6 +2,7 @@
import {
CHANGE_VOTE,
CLEAR_POLLS,
RESET_NB_UNREAD_POLLS,
RECEIVE_ANSWER,
RECEIVE_POLL,
@ -10,6 +11,17 @@ import {
} from './actionTypes';
import type { Answer, Poll } from './types';
/**
* Action to signal that existing polls needs to be cleared from state.
*
* @returns {{
* type: CLEAR_POLLS
* }}
*/
export const clearPolls = () => {
return { type: CLEAR_POLLS };
};
/**
* Action to signal that a poll's vote will be changed.
*

View File

@ -4,6 +4,7 @@ import { ReducerRegistry } from '../base/redux';
import {
CHANGE_VOTE,
CLEAR_POLLS,
RECEIVE_POLL,
RECEIVE_ANSWER,
REGISTER_VOTE,
@ -38,6 +39,13 @@ ReducerRegistry.register('features/polls', (state = INITIAL_STATE, action) => {
};
}
case CLEAR_POLLS: {
return {
...state,
...INITIAL_STATE
};
}
// Reducer triggered when a poll is received
case RECEIVE_POLL: {
const newState = {

View File

@ -9,7 +9,7 @@ import {
showNotification
} from '../notifications';
import { receiveAnswer, receivePoll } from './actions';
import { clearPolls, receiveAnswer, receivePoll } from './actions';
import { COMMAND_NEW_POLL, COMMAND_ANSWER_POLL, COMMAND_OLD_POLLS } from './constants';
import type { Answer, Poll } from './types';
@ -122,6 +122,9 @@ StateListenerRegistry.register(
conference.on(JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED, receiveMessage);
conference.on(JitsiConferenceEvents.NON_PARTICIPANT_MESSAGE_RECEIVED, receiveMessage);
// clean old polls
store.dispatch(clearPolls());
}
}
);