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

33 lines
659 B
JavaScript
Raw Normal View History

2016-10-30 16:12:35 +01:00
const FavoriteButton = {
props: ['status'],
data () {
return {
animated: false
}
},
2016-10-30 16:12:35 +01:00
methods: {
favorite () {
if (!this.status.favorited) {
2016-11-07 15:04:27 +01:00
this.$store.dispatch('favorite', {id: this.status.id})
2016-10-30 16:12:35 +01:00
} else {
2016-11-07 15:04:27 +01:00
this.$store.dispatch('unfavorite', {id: this.status.id})
2016-10-30 16:12:35 +01:00
}
this.animated = true
setTimeout(() => {
this.animated = false
}, 500)
2016-10-30 16:12:35 +01:00
}
},
computed: {
classes () {
return {
'icon-star-empty': !this.status.favorited,
'icon-star': this.status.favorited,
'animate-spin': this.animated
2016-10-30 16:12:35 +01:00
}
}
}
}
export default FavoriteButton