diff options
author | Jonas Sulzer <jonas@violoncello.ch> | 2019-05-28 16:08:09 +0200 |
---|---|---|
committer | Jonas Sulzer <jonas@violoncello.ch> | 2019-05-28 16:08:09 +0200 |
commit | f117996654d3bf3a21cb3bad0997fbdf87b6143d (patch) | |
tree | bee95b3a758ee1a2d0996dfd309ed63b5974cabb /src | |
parent | bc634c42a8713a7ba7e76e76dd924ef1f7d94bbe (diff) |
🐛 FIX: also toggle boosted state on the chached object inside of the Announce
Signed-off-by: Jonas Sulzer <jonas@violoncello.ch>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/TimelineContent.vue | 11 | ||||
-rw-r--r-- | src/components/TimelineEntry.vue | 8 | ||||
-rw-r--r-- | src/store/timeline.js | 18 |
3 files changed, 26 insertions, 11 deletions
diff --git a/src/components/TimelineContent.vue b/src/components/TimelineContent.vue index e2423425..7e86b0cc 100644 --- a/src/components/TimelineContent.vue +++ b/src/components/TimelineContent.vue @@ -64,7 +64,8 @@ export default { }, mixins: [popoverMenu, currentUser], props: { - item: { type: Object, default: () => {} } + item: { type: Object, default: () => {} }, + parentAnnounce: { type: Object, default: () => {} } }, data() { return { @@ -131,10 +132,14 @@ export default { this.$root.$emit('composer-reply', this.item) }, boost() { + let params = { + post: this.item, + parentAnnounce: this.parentAnnounce + } if (this.isBoosted) { - this.$store.dispatch('postUnBoost', this.item) + this.$store.dispatch('postUnBoost', params) } else { - this.$store.dispatch('postBoost', this.item) + this.$store.dispatch('postBoost', params) } } } diff --git a/src/components/TimelineEntry.vue b/src/components/TimelineEntry.vue index fa3d555b..03d25ad3 100644 --- a/src/components/TimelineEntry.vue +++ b/src/components/TimelineEntry.vue @@ -14,7 +14,7 @@ </a> {{ boosted }} </div> - <timeline-content :item="entryContent" /> + <timeline-content :item="entryContent" :parentAnnounce="isBoost" /> </div> </template> @@ -40,7 +40,11 @@ export default { } else { return this.item } - + }, + isBoost() { + if (this.item.type === 'Announce'){ + return this.item + } }, boosted() { return t('social', 'boosted') diff --git a/src/store/timeline.js b/src/store/timeline.js index f2d72d76..0e39d883 100644 --- a/src/store/timeline.js +++ b/src/store/timeline.js @@ -54,11 +54,17 @@ const mutations = { setAccount(state, account) { state.account = account }, - boostPost(state, post) { + boostPost(state, { post, parentAnnounce }) { Vue.set(state.timeline[post.id].action.values, 'boosted', true) + if (parentAnnounce) { + Vue.set(state.timeline[parentAnnounce.id].cache[parentAnnounce.object].action.values, 'boosted', true) + } }, - unboostPost(state, post) { + unboostPost(state, { post, parentAnnounce }) { Vue.set(state.timeline[post.id].action.values, 'boosted', false) + if (parentAnnounce) { + Vue.set(state.timeline[parentAnnounce.id].cache[parentAnnounce.object].action.values, 'boosted', false) + } } } const getters = { @@ -103,10 +109,10 @@ const actions = { console.error('Failed to delete the post', error) }) }, - postBoost(context, post) { + postBoost(context, { post, parentAnnounce }) { return new Promise((resolve, reject) => { axios.post(OC.generateUrl(`apps/social/api/v1/post/boost?postId=${post.id}`)).then((response) => { - context.commit('boostPost', post) + context.commit('boostPost', { post, parentAnnounce }) // eslint-disable-next-line no-console console.log('Post boosted with token ' + response.data.result.token) resolve(response) @@ -117,9 +123,9 @@ const actions = { }) }) }, - postUnBoost(context, post) { + postUnBoost(context, { post, parentAnnounce }) { return axios.delete(OC.generateUrl(`apps/social/api/v1/post/boost?postId=${post.id}`)).then((response) => { - context.commit('unboostPost', post) + context.commit('unboostPost', { post, parentAnnounce }) // eslint-disable-next-line no-console console.log('Boost deleted with token ' + response.data.result.token) }).catch((error) => { |