From edf7f6039c7c2014b2103c2382fa1eeb7361cda2 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 11 May 2023 18:13:13 +0800 Subject: [PATCH] More sort, still not perfect This proves to be more difficult than I thought --- src/utils/timeline-utils.jsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/utils/timeline-utils.jsx b/src/utils/timeline-utils.jsx index afe79ea2..e83ca5cf 100644 --- a/src/utils/timeline-utils.jsx +++ b/src/utils/timeline-utils.jsx @@ -119,9 +119,12 @@ export function groupContext(items) { // Sort items by checking inReplyToId contexts.forEach((context) => { context.sort((a, b) => { - if (a.inReplyToId === b.id) return 1; - if (b.inReplyToId === a.id) return -1; - return 0; + if (!a.inReplyToId && !b.inReplyToId) { + return new Date(a.createdAt) - new Date(b.createdAt); + } + if (!a.inReplyToId) return -1; + if (!b.inReplyToId) return 1; + return new Date(a.createdAt) - new Date(b.createdAt); }); });