kopia lustrzana https://github.com/nextcloud/social
🐛 FIX: also toggle boosted state on the chached object inside of the Announce
Signed-off-by: Jonas Sulzer <jonas@violoncello.ch>pull/546/head
rodzic
bc634c42a8
commit
f117996654
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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) => {
|
||||
|
|
Ładowanie…
Reference in New Issue