[Perf] Chats: Use deep equal check after detecting language
This commit is contained in:
parent
a960f3e473
commit
8b717b010f
@ -2578,7 +2578,7 @@ addActionHandler('updateChatDetectedLanguage', (global, actions, payload): Actio
|
||||
global = getGlobal();
|
||||
global = updateChat(global, chatId, {
|
||||
detectedLanguage,
|
||||
});
|
||||
}, undefined, true);
|
||||
|
||||
return global;
|
||||
});
|
||||
|
||||
@ -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<T extends GlobalState>(
|
||||
}
|
||||
|
||||
export function updateChat<T extends GlobalState>(
|
||||
global: T, chatId: string, chatUpdate: Partial<ApiChat>, noOmitUnreadReactionCount = false,
|
||||
global: T, chatId: string, chatUpdate: Partial<ApiChat>, 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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user