logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe
commit: 32e20b2e025e20f38b4acdea55a13a647463a9f1
parent: 9e61ab577b98643e6c0c88785f365c554b3ab8b1
Author: Roger Braun <roger@rogerbraun.net>
Date:   Sat, 29 Jul 2017 18:53:49 +0200

Only run through replies once.

Diffstat:

Msrc/components/conversation/conversation.js27+++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)

diff --git 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) {