🐛 FIX: also toggle boosted state on the chached object inside of the Announce

Signed-off-by: Jonas Sulzer <jonas@violoncello.ch>
pull/546/head
Jonas Sulzer 2019-05-28 16:08:09 +02:00
rodzic bc634c42a8
commit f117996654
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6D1DC8E0D9904C83
3 zmienionych plików z 26 dodań i 11 usunięć

Wyświetl plik

@ -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)
}
}
}

Wyświetl plik

@ -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')

Wyświetl plik

@ -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) => {