Message List: Fix animation in small chats

This commit is contained in:
Alexander Zinchuk 2021-05-31 19:50:10 +03:00
parent deee9cffc8
commit 7681f5998c

View File

@ -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;
}
}