From a39fc49e848c1444f76a7528eac4a7733199b336 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 28 Mar 2019 10:02:33 -0400 Subject: [PATCH] #433 - update sort by for conversation --- src/components/conversation/conversation.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index f43f9c5e..69058bf6 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -5,7 +5,19 @@ import Status from '../status/status.vue' const sortById = (a, b) => { const idA = a.type === 'retweet' ? a.retweeted_status.id : a.id const idB = b.type === 'retweet' ? b.retweeted_status.id : b.id - return idA < idB ? -1 : 1 + const seqA = Number(idA) + const seqB = Number(idB) + const isSeqA = !Number.isNaN(seqA) + const isSeqB = !Number.isNaN(seqB) + if (isSeqA && isSeqB) { + return seqA < seqB ? -1 : 1 + } else if (isSeqA && !isSeqB) { + return -1 + } else if (!isSeqA && isSeqB) { + return 1 + } else { + return idA < idB ? -1 : 1 + } } const sortAndFilterConversation = (conversation, statusoid) => {