get statuses in a conversation from the global repository instead of local state

This commit is contained in:
taehoon 2019-04-09 11:08:39 -04:00
parent 8c2efc5a5c
commit 724602bdc1
1 changed files with 10 additions and 20 deletions

View File

@ -36,8 +36,7 @@ const conversation = {
data () {
return {
highlight: null,
expanded: false,
converationStatusIds: []
expanded: false
}
},
props: [
@ -54,15 +53,6 @@ const conversation = {
status () {
return this.statusoid
},
idsToShow () {
if (this.converationStatusIds.length > 0) {
return this.converationStatusIds
} else if (this.statusId) {
return [this.statusId]
} else {
return []
}
},
statusId () {
if (this.statusoid.retweeted_status) {
return this.statusoid.retweeted_status.id
@ -70,6 +60,13 @@ const conversation = {
return this.statusoid.id
}
},
conversationId () {
if (this.statusoid.retweeted_status) {
return this.statusoid.retweeted_status.statusnet_conversation_id
} else {
return this.statusoid.statusnet_conversation_id
}
},
conversation () {
if (!this.status) {
return []
@ -79,11 +76,8 @@ const conversation = {
return [this.status]
}
const statusesObject = this.$store.state.statuses.allStatusesObject
const conversation = this.idsToShow.reduce((acc, id) => {
acc.push(statusesObject[id])
return acc
}, [])
const statuses = this.$store.state.statuses.allStatuses
const conversation = filter(statuses, { statusnet_conversation_id: this.conversationId })
const statusIndex = findIndex(conversation, { id: this.statusId })
if (statusIndex !== -1) {
@ -131,10 +125,6 @@ const conversation = {
.then(({ancestors, descendants}) => {
this.$store.dispatch('addNewStatuses', { statuses: ancestors })
this.$store.dispatch('addNewStatuses', { statuses: descendants })
set(this, 'converationStatusIds', [].concat(
ancestors.map(_ => _.id).filter(_ => _ !== this.statusId),
this.statusId,
descendants.map(_ => _.id).filter(_ => _ !== this.statusId)))
})
.then(() => this.setHighlight(this.statusId))
} else {