diff --git a/src/api/gramjs/updater.ts b/src/api/gramjs/updater.ts index f0f1d98a7..21b87f4ed 100644 --- a/src/api/gramjs/updater.ts +++ b/src/api/gramjs/updater.ts @@ -80,9 +80,6 @@ export function init(_onUpdate: OnApiUpdate) { } const sentMessageIds = new Set(); -// Workaround for a situation when an incorrect update comes with an undefined property `adminRights` -let shouldIgnoreNextChannelUpdate = false; -const IGNORE_NEXT_CHANNEL_UPDATE_TIMEOUT = 2000; function dispatchUserAndChatUpdates(entities: (GramJs.TypeUser | GramJs.TypeChat)[]) { entities @@ -756,18 +753,6 @@ export function updater(update: Update, originRequest?: GramJs.AnyRequest) { )); if (channel instanceof GramJs.Channel) { - if (shouldIgnoreNextChannelUpdate) { - shouldIgnoreNextChannelUpdate = false; - return; - } - - if (originRequest instanceof GramJs.messages.ToggleNoForwards) { - shouldIgnoreNextChannelUpdate = true; - setTimeout(() => { - shouldIgnoreNextChannelUpdate = false; - }, IGNORE_NEXT_CHANNEL_UPDATE_TIMEOUT); - } - const chat = buildApiChatFromPreview(channel); if (chat) { onUpdate({ diff --git a/src/global/reducers/chats.ts b/src/global/reducers/chats.ts index f13cfb08c..bcaf7d239 100644 --- a/src/global/reducers/chats.ts +++ b/src/global/reducers/chats.ts @@ -130,9 +130,15 @@ function getUpdatedChat( const chat = byId[chatId]; const omitProps: (keyof ApiChat)[] = []; - const shouldOmitMinInfo = chatUpdate.isMin && chat && !chat.isMin; - if (shouldOmitMinInfo) { + const shouldIgnoreUndefinedFields = chatUpdate.isMin && chat && !chat.isMin; + if (shouldIgnoreUndefinedFields) { omitProps.push('isMin', 'accessHash'); + Object.keys(chatUpdate).forEach((key) => { + const prop = key as keyof ApiChat; + if (chatUpdate[prop] === undefined) { + omitProps.push(prop); + } + }); } if (!noOmitUnreadReactionCount) { diff --git a/src/global/reducers/users.ts b/src/global/reducers/users.ts index 55bc4486f..68329ce72 100644 --- a/src/global/reducers/users.ts +++ b/src/global/reducers/users.ts @@ -115,9 +115,15 @@ function getUpdatedUser(global: GlobalState, userId: string, userUpdate: Partial const user = byId[userId]; const omitProps: (keyof ApiUser)[] = []; - const shouldOmitMinInfo = userUpdate.isMin && user && !user.isMin; - if (shouldOmitMinInfo) { + const shouldIgnoreUndefinedFields = userUpdate.isMin && user && !user.isMin; + if (shouldIgnoreUndefinedFields) { omitProps.push('isMin', 'accessHash'); + Object.keys(userUpdate).forEach((key) => { + const prop = key as keyof ApiUser; + if (userUpdate[prop] === undefined) { + omitProps.push(prop); + } + }); } if (areDeepEqual(user?.usernames, userUpdate.usernames)) {