refactoring

This commit is contained in:
taehoon 2019-08-30 12:11:59 -04:00
parent 214ab22c4c
commit c1f3b0dc75
1 changed files with 8 additions and 6 deletions

View File

@ -57,7 +57,7 @@ const conversation = {
if (this.status.retweeted_status) { if (this.status.retweeted_status) {
return this.status.retweeted_status.id return this.status.retweeted_status.id
} else { } else {
return this.status.id return this.statusoid
} }
}, },
conversationId () { conversationId () {
@ -120,23 +120,25 @@ const conversation = {
methods: { methods: {
fetchConversation () { fetchConversation () {
if (this.status) { if (this.status) {
this.$store.state.api.backendInteractor.fetchConversation({ id: this.status.id }) this.$store.state.api.backendInteractor.fetchConversation({ id: this.statusoid })
.then(({ ancestors, descendants }) => { .then(({ ancestors, descendants }) => {
this.$store.dispatch('addNewStatuses', { statuses: ancestors }) this.$store.dispatch('addNewStatuses', { statuses: ancestors })
this.$store.dispatch('addNewStatuses', { statuses: descendants }) this.$store.dispatch('addNewStatuses', { statuses: descendants })
this.setHighlight(this.statusId)
}) })
.then(() => this.setHighlight(this.statusId))
} else { } else {
this.$store.state.api.backendInteractor.fetchStatus({ id: this.statusoid }) this.$store.state.api.backendInteractor.fetchStatus({ id: this.statusoid })
.then((status) => this.$store.dispatch('addNewStatuses', { statuses: [status] })) .then((status) => {
.then(() => this.fetchConversation()) this.$store.dispatch('addNewStatuses', { statuses: [status] })
this.fetchConversation()
})
} }
}, },
getReplies (id) { getReplies (id) {
return this.replies[id] || [] return this.replies[id] || []
}, },
focused (id) { focused (id) {
return (this.isExpanded) && id === this.status.id return (this.isExpanded) && id === this.statusoid
}, },
setHighlight (id) { setHighlight (id) {
if (!id) return if (!id) return