diff --git a/src/global/actions/api/chats.ts b/src/global/actions/api/chats.ts index f550bc895..470dec615 100644 --- a/src/global/actions/api/chats.ts +++ b/src/global/actions/api/chats.ts @@ -2578,7 +2578,7 @@ addActionHandler('updateChatDetectedLanguage', (global, actions, payload): Actio global = getGlobal(); global = updateChat(global, chatId, { detectedLanguage, - }); + }, undefined, true); return global; }); diff --git a/src/global/reducers/chats.ts b/src/global/reducers/chats.ts index e3850922f..afbbfd0f8 100644 --- a/src/global/reducers/chats.ts +++ b/src/global/reducers/chats.ts @@ -6,7 +6,7 @@ import type { ChatListType, GlobalState } from '../types'; import { ARCHIVED_FOLDER_ID } from '../../config'; import { areDeepEqual } from '../../util/areDeepEqual'; import { - areSortedArraysEqual, buildCollectionByKey, omit, unique, + areSortedArraysEqual, buildCollectionByKey, omit, pick, unique, } from '../../util/iteratees'; import { selectChat, selectChatFullInfo } from '../selectors'; import { updateThread, updateThreadInfo } from './messages'; @@ -157,10 +157,18 @@ export function removeUnreadMentions( } export function updateChat( - global: T, chatId: string, chatUpdate: Partial, noOmitUnreadReactionCount = false, + global: T, chatId: string, chatUpdate: Partial, noOmitUnreadReactionCount = false, withDeepCheck = false, ): T { const { byId } = global.chats; + const chat = byId[chatId]; + if (withDeepCheck && chat) { + const updateKeys = Object.keys(chatUpdate) as (keyof ApiChat)[]; + if (areDeepEqual(pick(chat, updateKeys), chatUpdate)) { + return global; + } + } + const updatedChat = getUpdatedChat(global, chatId, chatUpdate, noOmitUnreadReactionCount); if (!updatedChat) { return global;