From c986ea7953e8e246ab667ceffa9e9e39247701e7 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Sun, 23 Jul 2023 10:08:11 +0200 Subject: [PATCH] [Perf] Fix broken `addUsers/addChats` optimization --- src/global/reducers/chats.ts | 6 ++++++ src/global/reducers/users.ts | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/global/reducers/chats.ts b/src/global/reducers/chats.ts index ffc2fa865..505f097b7 100644 --- a/src/global/reducers/chats.ts +++ b/src/global/reducers/chats.ts @@ -141,6 +141,11 @@ export function addChats(global: T, newById: Record>((acc, id) => { + const existingChat = byId[id]; + if (existingChat && !existingChat.isMin) { + return acc; + } + const updatedChat = getUpdatedChat(global, id, newById[id]); if (updatedChat) { acc[id] = updatedChat; @@ -148,6 +153,7 @@ export function addChats(global: T, newById: Record(global: T, newById: Record>((acc, id) => { + const existingUser = byId[id]; + if (existingUser && !existingUser.isMin) { + return acc; + } + const updatedUser = getUpdatedUser(global, id, newById[id]); if (updatedUser) { acc[id] = updatedUser; @@ -90,6 +95,7 @@ export function addUsers(global: T, newById: Record