Fetching convos via MastoAPI. Had to change conversation component a bit for

better support, since MastoAPI doesn't have coversation ids
This commit is contained in:
Henry Jameson 2019-03-09 18:33:49 +02:00
parent 09736691ea
commit 49b0f0a04a
2 changed files with 35 additions and 23 deletions

View file

@ -25,7 +25,8 @@ const sortAndFilterConversation = (conversation) => {
const conversation = {
data () {
return {
highlight: null
highlight: null,
relevantIds: []
}
},
props: [
@ -48,9 +49,11 @@ const conversation = {
return []
}
const conversationId = this.status.statusnet_conversation_id
const statuses = this.$store.state.statuses.allStatuses
const conversation = filter(statuses, { statusnet_conversation_id: conversationId })
const statusesObject = this.$store.state.statuses.allStatusesObject
const conversation = this.relevantIds.reduce((acc, id) => {
acc.push(statusesObject[id])
return acc
}, [])
return sortAndFilterConversation(conversation)
},
replies () {
@ -83,15 +86,13 @@ const conversation = {
methods: {
fetchConversation () {
if (this.status) {
const conversationId = this.status.statusnet_conversation_id
const conversationId = this.status.id
this.$store.state.api.backendInteractor.fetchConversation({id: conversationId})
.then((statuses) => this.$store.dispatch('addNewStatuses', { statuses }))
.then((statuses) => {
this.$store.dispatch('addNewStatuses', { statuses })
statuses.forEach(status => this.relevantIds.push(status.id))
})
.then(() => this.setHighlight(this.statusId))
} else {
const id = this.$route.params.id
this.$store.state.api.backendInteractor.fetchStatus({id})
.then((status) => this.$store.dispatch('addNewStatuses', { statuses: [status] }))
.then(() => this.fetchConversation())
}
},
getReplies (id) {