[Perf] Fix broken addUsers/addChats optimization (follow-up)

This commit is contained in:
Alexander Zinchuk 2023-07-27 11:48:06 +02:00
parent cd15c71b3d
commit 87d73bf6bc
2 changed files with 9 additions and 5 deletions

View File

@ -1,6 +1,6 @@
import type { GlobalState } from '../types';
import type {
ApiChat, ApiChatMember, ApiTopic, ApiPhoto, ApiChatFullInfo,
ApiChat, ApiChatFullInfo, ApiChatMember, ApiPhoto, ApiTopic,
} from '../../api/types';
import { ARCHIVED_FOLDER_ID } from '../../config';
@ -142,11 +142,13 @@ export function addChats<T extends GlobalState>(global: T, newById: Record<strin
const addedById = Object.keys(newById).reduce<Record<string, ApiChat>>((acc, id) => {
const existingChat = byId[id];
if (existingChat && !existingChat.isMin) {
const newChat = newById[id];
if (existingChat && !existingChat.isMin && (newChat.isMin || existingChat.accessHash === newChat.accessHash)) {
return acc;
}
const updatedChat = getUpdatedChat(global, id, newById[id]);
const updatedChat = getUpdatedChat(global, id, newChat);
if (updatedChat) {
acc[id] = updatedChat;
if (!isUpdated) {

View File

@ -84,11 +84,13 @@ export function addUsers<T extends GlobalState>(global: T, newById: Record<strin
const addedById = Object.keys(newById).reduce<Record<string, ApiUser>>((acc, id) => {
const existingUser = byId[id];
if (existingUser && !existingUser.isMin) {
const newUser = newById[id];
if (existingUser && !existingUser.isMin && (newUser.isMin || existingUser.accessHash === newUser.accessHash)) {
return acc;
}
const updatedUser = getUpdatedUser(global, id, newById[id]);
const updatedUser = getUpdatedUser(global, id, newUser);
if (updatedUser) {
acc[id] = updatedUser;
if (!isUpdated) {