More sort, still not perfect

This proves to be more difficult than I thought
This commit is contained in:
Lim Chee Aun 2023-05-11 18:13:13 +08:00
parent 6fcbc9dfa4
commit edf7f6039c

View file

@ -119,9 +119,12 @@ export function groupContext(items) {
// Sort items by checking inReplyToId // Sort items by checking inReplyToId
contexts.forEach((context) => { contexts.forEach((context) => {
context.sort((a, b) => { context.sort((a, b) => {
if (a.inReplyToId === b.id) return 1; if (!a.inReplyToId && !b.inReplyToId) {
if (b.inReplyToId === a.id) return -1; return new Date(a.createdAt) - new Date(b.createdAt);
return 0; }
if (!a.inReplyToId) return -1;
if (!b.inReplyToId) return 1;
return new Date(a.createdAt) - new Date(b.createdAt);
}); });
}); });