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/store | |
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/store')
-rw-r--r-- | src/store/timeline.js | 18 |
1 files changed, 12 insertions, 6 deletions
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) => { |