diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index 059028f9..4ee6c32e 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -1,4 +1,4 @@ -import { find, filter, sortBy } from 'lodash' +import { reduce, find, filter, sortBy } from 'lodash' import { statusType } from '../../modules/statuses.js' import Status from '../status/status.vue' @@ -33,6 +33,19 @@ const conversation = { const statuses = this.$store.state.statuses.allStatuses const conversation = filter(statuses, { statusnet_conversation_id: conversationId }) return sortAndFilterConversation(conversation) + }, + replies () { + return reduce(this.conversation, (result, {id, in_reply_to_status_id}) => { + const irid = Number(in_reply_to_status_id) + if (irid) { + result[irid] = result[irid] || [] + result[irid].push({ + name: `#${id}`, + id: id + }) + } + return result + }, {}) } }, components: { @@ -59,18 +72,8 @@ const conversation = { } }, getReplies (id) { - let res = [] id = Number(id) - let i - for (i = 0; i < this.conversation.length; i++) { - if (Number(this.conversation[i].in_reply_to_status_id) === id) { - res.push({ - name: `#${i}`, - id: this.conversation[i].id - }) - } - } - return res + return this.replies[id] || [] }, focused (id) { if (this.statusoid.retweeted_status) {