diff options
| author | dave <starpumadev@gmail.com> | 2019-03-25 14:47:54 -0400 |
|---|---|---|
| committer | dave <starpumadev@gmail.com> | 2019-03-25 14:47:54 -0400 |
| commit | 6143b1ce0febe0451305918d1c735c4c23071701 (patch) | |
| tree | 4be42874c05043599caf80894808842c674791f1 /src/components/conversation/conversation.js | |
| parent | 6a9159b25598d578018643673568bbcd06ea1e12 (diff) | |
| parent | 854d0e80512d2da80cd5153144698a5148da4aa6 (diff) | |
Resolve merge conflict,
Fix few issues (conversation page highlight, fetch conversation, ...)
Diffstat (limited to 'src/components/conversation/conversation.js')
| -rw-r--r-- | src/components/conversation/conversation.js | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index 5a9568a9..c57c7e06 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -1,4 +1,5 @@ import { reduce, filter, findIndex } from 'lodash' +import { set } from 'vue' import Status from '../status/status.vue' const sortById = (a, b) => { @@ -26,7 +27,8 @@ const conversation = { data () { return { highlight: null, - expanded: false + expanded: false, + converationStatusIds: [] } }, props: [ @@ -38,6 +40,15 @@ 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 @@ -54,14 +65,17 @@ const conversation = { return [this.status] } - 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.idsToShow.reduce((acc, id) => { + acc.push(statusesObject[id]) + return acc + }, []) const statusIndex = findIndex(conversation, { id: this.statusId }) if (statusIndex !== -1) { conversation[statusIndex] = this.status } + return sortAndFilterConversation(conversation) }, replies () { @@ -99,9 +113,15 @@ const conversation = { methods: { fetchConversation () { if (this.status) { - const conversationId = this.status.statusnet_conversation_id - this.$store.state.api.backendInteractor.fetchConversation({id: conversationId}) - .then((statuses) => this.$store.dispatch('addNewStatuses', { statuses })) + this.$store.state.api.backendInteractor.fetchConversation({id: this.status.id}) + .then(({ancestors, descendants}) => { + this.$store.dispatch('addNewStatuses', { statuses: ancestors }) + this.$store.dispatch('addNewStatuses', { statuses: descendants }) + set(this, 'converationStatusIds', [].concat( + ancestors.map(_ => _.id), + this.statusId, + descendants.map(_ => _.id))) + }) .then(() => this.setHighlight(this.statusId)) } else { const id = this.$route.params.id |
