2016-10-30 08:12:35 -07:00
|
|
|
const FavoriteButton = {
|
2018-02-01 14:45:29 -08:00
|
|
|
props: ['status', 'loggedIn'],
|
2017-03-08 20:45:40 -08:00
|
|
|
data () {
|
|
|
|
return {
|
2018-10-16 06:15:04 -07:00
|
|
|
hidePostStatsLocal: typeof this.$store.state.config.hidePostStats === 'undefined'
|
2018-10-16 06:09:29 -07:00
|
|
|
? this.$store.state.instance.hidePostStats
|
|
|
|
: this.$store.state.config.hidePostStats,
|
2017-03-08 20:45:40 -08:00
|
|
|
animated: false
|
|
|
|
}
|
|
|
|
},
|
2016-10-30 08:12:35 -07:00
|
|
|
methods: {
|
|
|
|
favorite () {
|
|
|
|
if (!this.status.favorited) {
|
2019-07-05 00:02:14 -07:00
|
|
|
this.$store.dispatch('favorite', { id: this.status.id })
|
2016-10-30 08:12:35 -07:00
|
|
|
} else {
|
2019-07-05 00:02:14 -07:00
|
|
|
this.$store.dispatch('unfavorite', { id: this.status.id })
|
2016-10-30 08:12:35 -07:00
|
|
|
}
|
2017-03-08 20:45:40 -08:00
|
|
|
this.animated = true
|
|
|
|
setTimeout(() => {
|
|
|
|
this.animated = false
|
|
|
|
}, 500)
|
2016-10-30 08:12:35 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
classes () {
|
|
|
|
return {
|
|
|
|
'icon-star-empty': !this.status.favorited,
|
2017-03-08 20:45:40 -08:00
|
|
|
'icon-star': this.status.favorited,
|
|
|
|
'animate-spin': this.animated
|
2016-10-30 08:12:35 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default FavoriteButton
|