Only run through replies once.
This commit is contained in:
parent
9e61ab577b
commit
32e20b2e02
1 changed files with 15 additions and 12 deletions
|
@ -1,4 +1,4 @@
|
||||||
import { find, filter, sortBy } from 'lodash'
|
import { reduce, find, filter, sortBy } from 'lodash'
|
||||||
import { statusType } from '../../modules/statuses.js'
|
import { statusType } from '../../modules/statuses.js'
|
||||||
import Status from '../status/status.vue'
|
import Status from '../status/status.vue'
|
||||||
|
|
||||||
|
@ -33,6 +33,19 @@ const conversation = {
|
||||||
const statuses = this.$store.state.statuses.allStatuses
|
const statuses = this.$store.state.statuses.allStatuses
|
||||||
const conversation = filter(statuses, { statusnet_conversation_id: conversationId })
|
const conversation = filter(statuses, { statusnet_conversation_id: conversationId })
|
||||||
return sortAndFilterConversation(conversation)
|
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: {
|
components: {
|
||||||
|
@ -59,18 +72,8 @@ const conversation = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getReplies (id) {
|
getReplies (id) {
|
||||||
let res = []
|
|
||||||
id = Number(id)
|
id = Number(id)
|
||||||
let i
|
return this.replies[id] || []
|
||||||
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
|
|
||||||
},
|
},
|
||||||
focused (id) {
|
focused (id) {
|
||||||
if (this.statusoid.retweeted_status) {
|
if (this.statusoid.retweeted_status) {
|
||||||
|
|
Loading…
Reference in a new issue