diff options
Diffstat (limited to 'src/components/conversation/conversation.js')
| -rw-r--r-- | src/components/conversation/conversation.js | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index 69058bf6..a2b3aeab 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -1,5 +1,4 @@ -import { reduce, filter, findIndex } from 'lodash' -import { set } from 'vue' +import { reduce, filter, findIndex, clone } from 'lodash' import Status from '../status/status.vue' const sortById = (a, b) => { @@ -36,14 +35,14 @@ const conversation = { data () { return { highlight: null, - expanded: false, - converationStatusIds: [] + expanded: false } }, props: [ 'statusoid', 'collapsable', - 'isPage' + 'isPage', + 'showPinned' ], created () { if (this.isPage) { @@ -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,12 +76,7 @@ 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 conversation = clone(this.$store.state.statuses.conversationsObject[this.conversationId]) const statusIndex = findIndex(conversation, { id: this.statusId }) if (statusIndex !== -1) { conversation[statusIndex] = this.status @@ -94,7 +86,8 @@ const conversation = { }, replies () { let i = 1 - return reduce(this.conversation, (result, {id, in_reply_to_status_id}) => { + // eslint-disable-next-line camelcase + return reduce(this.conversation, (result, { id, in_reply_to_status_id }) => { /* eslint-disable camelcase */ const irid = in_reply_to_status_id /* eslint-enable camelcase */ @@ -127,19 +120,15 @@ const conversation = { methods: { fetchConversation () { if (this.status) { - this.$store.state.api.backendInteractor.fetchConversation({id: this.status.id}) - .then(({ancestors, descendants}) => { + 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).filter(_ => _ !== this.statusId), - this.statusId, - descendants.map(_ => _.id).filter(_ => _ !== this.statusId))) }) .then(() => this.setHighlight(this.statusId)) } else { const id = this.$route.params.id - this.$store.state.api.backendInteractor.fetchStatus({id}) + this.$store.state.api.backendInteractor.fetchStatus({ id }) .then((status) => this.$store.dispatch('addNewStatuses', { statuses: [status] })) .then(() => this.fetchConversation()) } @@ -151,7 +140,9 @@ const conversation = { return (this.isExpanded) && id === this.status.id }, setHighlight (id) { + if (!id) return this.highlight = id + this.$store.dispatch('fetchFavsAndRepeats', id) }, getHighlight () { return this.isExpanded ? this.highlight : null |
