pleroma-fe/src/components/favorite_button/favorite_button.js

36 lines
747 B
JavaScript
Raw Normal View History

import { mapGetters } from 'vuex'
2016-10-31 02:12:35 +11:00
const FavoriteButton = {
props: ['status', 'loggedIn'],
data () {
return {
animated: false
}
},
2016-10-31 02:12:35 +11:00
methods: {
favorite () {
if (!this.status.favorited) {
2019-07-05 17:02:14 +10:00
this.$store.dispatch('favorite', { id: this.status.id })
2016-10-31 02:12:35 +11:00
} else {
2019-07-05 17:02:14 +10:00
this.$store.dispatch('unfavorite', { id: this.status.id })
2016-10-31 02:12:35 +11:00
}
this.animated = true
setTimeout(() => {
this.animated = false
}, 500)
2016-10-31 02:12:35 +11:00
}
},
computed: {
classes () {
return {
'icon-star-empty': !this.status.favorited,
'icon-star': this.status.favorited,
'animate-spin': this.animated
2016-10-31 02:12:35 +11:00
}
},
...mapGetters(['mergedConfig'])
2016-10-31 02:12:35 +11:00
}
}
export default FavoriteButton