From b5803fce9ed2bc9ebb16d40cb58984fb79f3206c Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Tue, 11 May 2021 23:18:08 +0300 Subject: [PATCH] Message List: Fix initial scroll in new channels --- src/modules/selectors/messages.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/selectors/messages.ts b/src/modules/selectors/messages.ts index 4090fbeec..c08785694 100644 --- a/src/modules/selectors/messages.ts +++ b/src/modules/selectors/messages.ts @@ -519,10 +519,13 @@ export function selectFirstUnreadId(global: GlobalState, chatId: number, threadI } const lastReadId = selectRealLastReadId(global, chatId, threadId); + if (!lastReadId) { + return undefined; + } if (outlyingIds) { const found = outlyingIds.find((id) => { - return !lastReadId || (id > lastReadId && byId[id] && (!byId[id].isOutgoing || byId[id].isFromScheduled)); + return id > lastReadId && byId[id] && (!byId[id].isOutgoing || byId[id].isFromScheduled); }); if (found) { return found; @@ -531,7 +534,7 @@ export function selectFirstUnreadId(global: GlobalState, chatId: number, threadI if (listedIds) { const found = listedIds.find((id) => { - return !lastReadId || (id > lastReadId && byId[id] && (!byId[id].isOutgoing || byId[id].isFromScheduled)); + return id > lastReadId && byId[id] && (!byId[id].isOutgoing || byId[id].isFromScheduled); }); if (found) { return found;