Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix(chat): clear and exclude deleted and moderated messages
7Prabhat9df588fffc8f
diff --git a/react/features/chat/components/native/ChatMessage.tsx b/react/features/chat/components/native/ChatMessage.tsxindex 240a79c43c..a9587b169b 100644--- a/react/features/chat/components/native/ChatMessage.tsx+++ b/react/features/chat/components/native/ChatMessage.tsx@@ -83,7 +83,9 @@ class ChatMessage extends Component<IChatMessageProps> {const messageText = message.isDeleted? this.props.t(localMessage ? 'chat.deletedMessageByMe' : 'chat.deletedMessage')- : getMessageText(this.props.message);+ : message.isModerated+ ? this.props.t('chat.moderatedMessage')+ : getMessageText(this.props.message);return (<View@@ -99,7 +101,7 @@ class ChatMessage extends Component<IChatMessageProps> {: this._renderMessageTextComponent(messageText) }{ this._renderPrivateNotice() }</View>- { !message.isDeleted && this._renderPrivateReplyButton() }+ { !message.isDeleted && !message.isModerated && this._renderPrivateReplyButton() }</View>{ this._renderTimestamp() }</View>diff --git a/react/features/chat/functions.ts b/react/features/chat/functions.tsindex b3de27b6c9..a0083fdc63 100644--- a/react/features/chat/functions.ts+++ b/react/features/chat/functions.ts@@ -470,7 +470,8 @@ const _getMessages = (state: IReduxState) => state['features/chat'].messages;/*** Returns all messages matching the current search query, in display order.- * Reaction and file messages are excluded since they have no searchable text.+ * Reaction and file messages are excluded since they have no searchable text, and deleted or+ * moderated messages are excluded since their original text is no longer shown.* Memoized: only recomputes when messages or the search query change.** @returns {IMessage[]}@@ -485,8 +486,12 @@ export const getChatSearchMatches = createSelector(return NO_SEARCH_MATCHES;}+ // The reducer already clears the text of deleted and moderated messages; skip them+ // here as well as a safeguard, so a removed message never shows up in the results.return messages.filter(message =>!message.isReaction+ && !message.isDeleted+ && !message.isModerated&& !isFileMessage(message)&& getMessageText(message).toLowerCase().includes(query));}diff --git a/react/features/chat/reducer.ts b/react/features/chat/reducer.tsindex b0821ad2a8..5e466c4be5 100644--- a/react/features/chat/reducer.ts+++ b/react/features/chat/reducer.ts@@ -211,6 +211,12 @@ ReducerRegistry.register<IChatState>('features/chat', (state = DEFAULT_STATE, acreturn m;}+ // A deleted or moderated message has had its text cleared, so an edit+ // arriving afterwards must not bring the text back.+ if (m.isDeleted || m.isModerated) {+ return m;+ }+applied = true;return {@@ -250,8 +256,11 @@ ReducerRegistry.register<IChatState>('features/chat', (state = DEFAULT_STATE, accase MODERATE_MESSAGE: {const messages = state.messages.map(message => {if (message.messageId === action.messageId) {+ // Clear the text, like RETRACT_MESSAGE does, so the removed content+ // does not stay in the state while the UI shows a placeholder.return {...message,+ message: '',isModerated: true,moderationReason: action.reason};