diff options
author | Jonas Sulzer <jonas@violoncello.ch> | 2019-04-22 19:56:40 +0200 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2019-05-03 16:31:15 -0100 |
commit | 360b69d02090a7798aeaa419d04beeda36941b4e (patch) | |
tree | 75689e6c71eee7aae4601b2ca2b69e6061dddd02 /src | |
parent | 055aa5865a8ab43d81a4cbf4503ef136dc66ae38 (diff) |
📦 NEW: unboost post if it was boosted previously
Signed-off-by: Jonas Sulzer <jonas@violoncello.ch>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/TimelineEntry.vue | 7 | ||||
-rw-r--r-- | src/store/timeline.js | 10 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/components/TimelineEntry.vue b/src/components/TimelineEntry.vue index 756e0afb..2adbd272 100644 --- a/src/components/TimelineEntry.vue +++ b/src/components/TimelineEntry.vue @@ -123,7 +123,12 @@ export default { this.$root.$emit('composer-reply', this.item) }, boost() { - this.$store.dispatch('postBoost', this.item) + if (this.item.action.values.boosted) { + this.$store.dispatch('postUnBoost', this.item) + } else { + this.$store.dispatch('postBoost', this.item) + } + } } } diff --git a/src/store/timeline.js b/src/store/timeline.js index 16188ef4..050e620b 100644 --- a/src/store/timeline.js +++ b/src/store/timeline.js @@ -109,6 +109,16 @@ const actions = { }) }) }, + postUnBoost(context, post) { + return axios.delete(OC.generateUrl(`apps/social/api/v1/post/boost?postId=${post.id}`)).then((response) => { + context.commit('removeBoost', post) + // eslint-disable-next-line no-console + console.log('Boost deleted with token ' + response.data.result.token) + }).catch((error) => { + OC.Notification.showTemporary('Failed to delete the boost') + console.error('Failed to delete the boost', error) + }) + }, refreshTimeline(context) { return this.dispatch('fetchTimeline', { sinceTimestamp: Math.floor(Date.now() / 1000) + 1 }) }, |