mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-08-11 19:23:03 +02:00
Fix logic for oldest-message detection on new message in focused convo and then paging
This commit is contained in:
@@ -127,8 +127,13 @@ export function useConversationMessages(
|
|||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Get the oldest message as cursor for the next page
|
// Get the true oldest message as cursor for the next page
|
||||||
const oldestMessage = messages[messages.length - 1];
|
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;
|
if (!oldestMessage) return;
|
||||||
|
|
||||||
setLoadingOlder(true);
|
setLoadingOlder(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user