[Perf] Fix broken addUsers/addChats optimization (follow-up)
This commit is contained in:
parent
cd15c71b3d
commit
87d73bf6bc
@ -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) {
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user