From 187d80066ec3da6ed7f3f37b09090a98b613b9c1 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Thu, 22 Aug 2024 11:37:34 -0700 Subject: [PATCH] Fix loading newer messages on scroll --- ts/models/conversations.ts | 3 +++ ts/state/ducks/conversations.ts | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index f65ca700831e..798bb80b5717 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -1561,6 +1561,7 @@ export class ConversationModel extends window.Backbone }); let messages: ReadonlyArray; + let unboundedFetch = true; if (metrics.oldestUnseen) { const unseen = await getMessageById(metrics.oldestUnseen.id); if (!unseen) { @@ -1587,6 +1588,7 @@ export class ConversationModel extends window.Backbone messages = [...older, unseen, ...newer]; metrics = freshMetrics; + unboundedFetch = false; } else { messages = await getOlderMessagesByConversation({ conversationId: this.id, @@ -1607,6 +1609,7 @@ export class ConversationModel extends window.Backbone conversationId: this.id, messages: cleaned, metrics, + unboundedFetch, }); } finally { finish(); diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index 968dcf0cef81..3b595eaa2731 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -439,6 +439,7 @@ export type ConversationPreloadDataType = ReadonlyDeep<{ conversationId: string; messages: ReadonlyArray; metrics: MessageMetricsType; + unboundedFetch: boolean; }>; export type MessagesByConversationType = ReadonlyDeep<{ @@ -5672,10 +5673,7 @@ export function reducer( return dropPreloadData(state); } - return updateMessageLookup(state, { - ...preloadData, - unboundedFetch: true, - }); + return updateMessageLookup(state, preloadData); } if (action.type === 'SET_MESSAGE_LOADING_STATE') { const { payload } = action;