[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 = getGlobal();
|
||||||
global = updateChat(global, chatId, {
|
global = updateChat(global, chatId, {
|
||||||
detectedLanguage,
|
detectedLanguage,
|
||||||
});
|
}, undefined, true);
|
||||||
|
|
||||||
return global;
|
return global;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import type { ChatListType, GlobalState } from '../types';
|
|||||||
import { ARCHIVED_FOLDER_ID } from '../../config';
|
import { ARCHIVED_FOLDER_ID } from '../../config';
|
||||||
import { areDeepEqual } from '../../util/areDeepEqual';
|
import { areDeepEqual } from '../../util/areDeepEqual';
|
||||||
import {
|
import {
|
||||||
areSortedArraysEqual, buildCollectionByKey, omit, unique,
|
areSortedArraysEqual, buildCollectionByKey, omit, pick, unique,
|
||||||
} from '../../util/iteratees';
|
} from '../../util/iteratees';
|
||||||
import { selectChat, selectChatFullInfo } from '../selectors';
|
import { selectChat, selectChatFullInfo } from '../selectors';
|
||||||
import { updateThread, updateThreadInfo } from './messages';
|
import { updateThread, updateThreadInfo } from './messages';
|
||||||
@ -157,10 +157,18 @@ export function removeUnreadMentions<T extends GlobalState>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function updateChat<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 {
|
): T {
|
||||||
const { byId } = global.chats;
|
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);
|
const updatedChat = getUpdatedChat(global, chatId, chatUpdate, noOmitUnreadReactionCount);
|
||||||
if (!updatedChat) {
|
if (!updatedChat) {
|
||||||
return global;
|
return global;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user