logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe
commit: 86773579ed924e0a8a38eac4812f1bc10e353870
parent: da3b604d9dd525c2f0114d2ae3090b137d9bb267
Author: Roger Braun <roger@rogerbraun.net>
Date:   Fri, 28 Jul 2017 11:19:56 +0200

Throttle getReplies so it isn't called that often.

Diffstat:

Msrc/components/conversation/conversation.js32+++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 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 { find, filter, sortBy, throttle } from 'lodash' import { statusType } from '../../modules/statuses.js' import Status from '../status/status.vue' @@ -7,6 +7,21 @@ const sortAndFilterConversation = (conversation) => { return sortBy(conversation, 'id') } +const getReplies = function (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 +} + const conversation = { data () { return { @@ -58,20 +73,7 @@ const conversation = { .then(() => this.fetchConversation()) } }, - 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 - }, + getReplies: throttle(getReplies, 1000), focused (id) { if (this.statusoid.retweeted_status) { return (id === this.statusoid.retweeted_status.id)