From 7681f5998c507a2324a4c72871f68902d7299a92 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Mon, 31 May 2021 19:50:10 +0300 Subject: [PATCH] Message List: Fix animation in small chats --- src/modules/actions/apiUpdaters/messages.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/modules/actions/apiUpdaters/messages.ts b/src/modules/actions/apiUpdaters/messages.ts index ad2ba9ed..615ff5a6 100644 --- a/src/modules/actions/apiUpdaters/messages.ts +++ b/src/modules/actions/apiUpdaters/messages.ts @@ -32,7 +32,9 @@ import { selectScheduledMessages, isMessageInCurrentMessageList, selectScheduledIds, - selectCurrentMessageList, selectRealLastReadId, selectViewportIds, + selectCurrentMessageList, + selectViewportIds, + selectFirstUnreadId, } from '../../selectors'; import { getMessageContent, isChatPrivate, isMessageLocal } from '../../helpers'; @@ -427,12 +429,12 @@ function updateListedAndViewportIds(global: GlobalState, message: ApiMessage) { global = updateListedIds(global, chatId, MAIN_THREAD_ID, [id]); if (selectIsViewportNewest(global, chatId, MAIN_THREAD_ID)) { - // Always keep at least one read message in the viewport list - const lastReadId = selectRealLastReadId(global, chatId, MAIN_THREAD_ID); + // Always keep the first uread message in the viewport list + const firstUnreadId = selectFirstUnreadId(global, chatId, MAIN_THREAD_ID); const newGlobal = addViewportId(global, chatId, MAIN_THREAD_ID, id); const newViewportIds = selectViewportIds(newGlobal, chatId, MAIN_THREAD_ID); - if (!lastReadId || newViewportIds!.includes(lastReadId)) { + if (!firstUnreadId || newViewportIds!.includes(firstUnreadId)) { global = newGlobal; } }