Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(breakout-rooms): Fix polls usage.

Дамян Минков32aa40b39677
diff --git a/doc/debian/jitsi-meet-prosody/prosody.cfg.lua-jvb.example b/doc/debian/jitsi-meet-prosody/prosody.cfg.lua-jvb.example
index 741594da19..5373a97764 100644
--- a/doc/debian/jitsi-meet-prosody/prosody.cfg.lua-jvb.example
+++ b/doc/debian/jitsi-meet-prosody/prosody.cfg.lua-jvb.example
@@ -124,4 +124,5 @@ Component "lobby.jitmeet.example.com" "muc"
muc_room_default_public_jids = true
modules_enabled = {
"muc_rate_limit";
+ "polls";
}
diff --git a/react/features/polls/actionTypes.js b/react/features/polls/actionTypes.js
index f48b725c11..ca9322fe7d 100644
--- a/react/features/polls/actionTypes.js
+++ b/react/features/polls/actionTypes.js
@@ -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.
diff --git a/react/features/polls/actions.js b/react/features/polls/actions.js
index af7a94798d..9fcbe234f7 100644
--- a/react/features/polls/actions.js
+++ b/react/features/polls/actions.js
@@ -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.
*
diff --git a/react/features/polls/reducer.js b/react/features/polls/reducer.js
index ef1d9d5fbd..12036c0aff 100644
--- a/react/features/polls/reducer.js
+++ b/react/features/polls/reducer.js
@@ -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 = {
diff --git a/react/features/polls/subscriber.js b/react/features/polls/subscriber.js
index 55c6fa46a5..10da8c5c50 100644
--- a/react/features/polls/subscriber.js
+++ b/react/features/polls/subscriber.js
@@ -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());
}
}
);