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(chat): Clear all state when changing room.

damencho9d6c38590cc2
diff --git a/react/features/chat/actionTypes.ts b/react/features/chat/actionTypes.ts
index 7db6605b65..1e6d3e562c 100644
--- a/react/features/chat/actionTypes.ts
+++ b/react/features/chat/actionTypes.ts
@@ -26,13 +26,13 @@ export const ADD_MESSAGE = 'ADD_MESSAGE';
export const ADD_MESSAGE_REACTION = 'ADD_MESSAGE_REACTION';
/**
- * The type of the action which signals to clear messages in Redux.
+ * The type of the action which signals to clear Redux.
*
* {
- * type: CLEAR_MESSAGES
+ * type: CLEAR_CHAT_STATE
* }
*/
-export const CLEAR_MESSAGES = 'CLEAR_MESSAGES';
+export const CLEAR_CHAT_STATE = 'CLEAR_CHAT_STATE';
/**
* The type of the action which signals the cancellation the chat panel.
diff --git a/react/features/chat/actions.any.ts b/react/features/chat/actions.any.ts
index 461f3505d5..dda4bac8cd 100644
--- a/react/features/chat/actions.any.ts
+++ b/react/features/chat/actions.any.ts
@@ -7,7 +7,7 @@ import { LOBBY_CHAT_INITIALIZED } from '../lobby/constants';
import {
ADD_MESSAGE,
ADD_MESSAGE_REACTION,
- CLEAR_MESSAGES,
+ CLEAR_CHAT_STATE,
CLOSE_CHAT,
EDIT_MESSAGE,
NOTIFY_PRIVATE_RECIPIENTS_CHANGED,
@@ -93,15 +93,15 @@ export function editMessage(message: Object) {
}
/**
- * Clears the chat messages in Redux.
+ * Clears the chat features state from Redux.
*
* @returns {{
- * type: CLEAR_MESSAGES
+ * type: CLEAR_CHAT_STATE
* }}
*/
-export function clearMessages() {
+export function clearChatState() {
return {
- type: CLEAR_MESSAGES
+ type: CLEAR_CHAT_STATE
};
}
diff --git a/react/features/chat/middleware.ts b/react/features/chat/middleware.ts
index e44688b395..6767a45a4f 100644
--- a/react/features/chat/middleware.ts
+++ b/react/features/chat/middleware.ts
@@ -51,7 +51,7 @@ import {
import {
addMessage,
addMessageReaction,
- clearMessages,
+ clearChatState,
closeChat,
notifyPrivateRecipientsChanged,
openChat,
@@ -352,7 +352,7 @@ StateListenerRegistry.register(
}
// Clear chat messages.
- dispatch(clearMessages());
+ dispatch(clearChatState());
}
});
diff --git a/react/features/chat/reducer.ts b/react/features/chat/reducer.ts
index 4eae8f837a..aa1629d5a0 100644
--- a/react/features/chat/reducer.ts
+++ b/react/features/chat/reducer.ts
@@ -7,7 +7,7 @@ import { IVisitorChatParticipant } from '../visitors/types';
import {
ADD_MESSAGE,
ADD_MESSAGE_REACTION,
- CLEAR_MESSAGES,
+ CLEAR_CHAT_STATE,
CLOSE_CHAT,
EDIT_MESSAGE,
NOTIFY_PRIVATE_RECIPIENTS_CHANGED,
@@ -140,11 +140,10 @@ ReducerRegistry.register<IChatState>('features/chat', (state = DEFAULT_STATE, ac
};
}
- case CLEAR_MESSAGES:
+ case CLEAR_CHAT_STATE:
return {
- ...state,
- lastReadMessage: undefined,
- messages: []
+ ...DEFAULT_STATE,
+ width: state.width
};
case EDIT_MESSAGE: {