diff options
| author | dave <starpumadev@gmail.com> | 2019-03-27 16:00:54 -0400 |
|---|---|---|
| committer | dave <starpumadev@gmail.com> | 2019-03-27 16:00:54 -0400 |
| commit | 43e97e590c98d1f1bb500f96d2b604b968fbbbb3 (patch) | |
| tree | 60ea44571b61d1c2f4bc47b3128e448a20e8386f /src/components/conversation/conversation.js | |
| parent | 0e2931e7de48d2e01aa8256f5f3f796c7d474865 (diff) | |
#433 - sort conversation for retweets and clean up
Diffstat (limited to 'src/components/conversation/conversation.js')
| -rw-r--r-- | src/components/conversation/conversation.js | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index 8ad1f44d..5357b67f 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -3,19 +3,9 @@ import { set } from 'vue' import Status from '../status/status.vue' const sortById = (a, b) => { - const seqA = Number(a.id) - const seqB = Number(b.id) - 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 a.id < b.id ? -1 : 1 - } + 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 sortAndFilterConversation = (conversation, statusoid) => { @@ -24,6 +14,8 @@ const sortAndFilterConversation = (conversation, statusoid) => { conversation, (status) => (status.type === 'retweet' || status.id !== statusoid.retweeted_status.id) ) + } else { + conversation = filter(conversation, (status) => status.type !== 'retweet') } return conversation.filter(_ => _).sort(sortById) } |
