From 526b00eda4924a5a3c5974b7647cb32c1ee80de4 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Tue, 15 Jun 2021 13:21:39 +0300 Subject: [PATCH] Message List: Another (2) attempt to fix marking all messages read --- src/modules/actions/apiUpdaters/messages.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/modules/actions/apiUpdaters/messages.ts b/src/modules/actions/apiUpdaters/messages.ts index 265f505c0..e87164902 100644 --- a/src/modules/actions/apiUpdaters/messages.ts +++ b/src/modules/actions/apiUpdaters/messages.ts @@ -36,6 +36,7 @@ import { selectViewportIds, selectFirstUnreadId, selectRealLastReadId, + selectChat, } from '../../selectors'; import { getMessageContent, isChatPrivate, isMessageLocal } from '../../helpers'; @@ -427,6 +428,12 @@ function updateWithLocalMedia( function updateListedAndViewportIds(global: GlobalState, message: ApiMessage) { const { id, chatId } = message; + const chat = selectChat(global, chatId); + const isUnreadChatNotLoaded = chat && chat.unreadCount && !selectListedIds(global, chatId, MAIN_THREAD_ID); + if (isUnreadChatNotLoaded) { + return global; + } + global = updateListedIds(global, chatId, MAIN_THREAD_ID, [id]); if (selectIsViewportNewest(global, chatId, MAIN_THREAD_ID)) {