Fix logic for oldest-message detection on new message in focused convo and then paging

This commit is contained in:
Jack Kingsman
2026-02-09 19:56:20 -08:00
parent ec97dfcee5
commit 9294ffe138

View File

@@ -127,8 +127,13 @@ export function useConversationMessages(
)
return;
// Get the oldest message as cursor for the next page
const oldestMessage = messages[messages.length - 1];
// Get the true oldest message as cursor for the next page
const oldestMessage = messages.reduce((oldest, msg) => {
if (!oldest) return msg;
if (msg.received_at < oldest.received_at) return msg;
if (msg.received_at === oldest.received_at && msg.id < oldest.id) return msg;
return oldest;
}, null as Message | null);
if (!oldestMessage) return;
setLoadingOlder(true);