Fix loading newer messages on scroll

This commit is contained in:
Fedor Indutny 2024-08-22 11:37:34 -07:00 committed by GitHub
parent c901708281
commit 187d80066e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View file

@ -1561,6 +1561,7 @@ export class ConversationModel extends window.Backbone
}); });
let messages: ReadonlyArray<MessageAttributesType>; let messages: ReadonlyArray<MessageAttributesType>;
let unboundedFetch = true;
if (metrics.oldestUnseen) { if (metrics.oldestUnseen) {
const unseen = await getMessageById(metrics.oldestUnseen.id); const unseen = await getMessageById(metrics.oldestUnseen.id);
if (!unseen) { if (!unseen) {
@ -1587,6 +1588,7 @@ export class ConversationModel extends window.Backbone
messages = [...older, unseen, ...newer]; messages = [...older, unseen, ...newer];
metrics = freshMetrics; metrics = freshMetrics;
unboundedFetch = false;
} else { } else {
messages = await getOlderMessagesByConversation({ messages = await getOlderMessagesByConversation({
conversationId: this.id, conversationId: this.id,
@ -1607,6 +1609,7 @@ export class ConversationModel extends window.Backbone
conversationId: this.id, conversationId: this.id,
messages: cleaned, messages: cleaned,
metrics, metrics,
unboundedFetch,
}); });
} finally { } finally {
finish(); finish();

View file

@ -439,6 +439,7 @@ export type ConversationPreloadDataType = ReadonlyDeep<{
conversationId: string; conversationId: string;
messages: ReadonlyArray<ReadonlyMessageAttributesType>; messages: ReadonlyArray<ReadonlyMessageAttributesType>;
metrics: MessageMetricsType; metrics: MessageMetricsType;
unboundedFetch: boolean;
}>; }>;
export type MessagesByConversationType = ReadonlyDeep<{ export type MessagesByConversationType = ReadonlyDeep<{
@ -5672,10 +5673,7 @@ export function reducer(
return dropPreloadData(state); return dropPreloadData(state);
} }
return updateMessageLookup(state, { return updateMessageLookup(state, preloadData);
...preloadData,
unboundedFetch: true,
});
} }
if (action.type === 'SET_MESSAGE_LOADING_STATE') { if (action.type === 'SET_MESSAGE_LOADING_STATE') {
const { payload } = action; const { payload } = action;