2016-10-31 02:12:35 +11:00
|
|
|
const FavoriteButton = {
|
2018-02-02 09:45:29 +11:00
|
|
|
props: ['status', 'loggedIn'],
|
2017-03-09 15:45:40 +11:00
|
|
|
data () {
|
|
|
|
return {
|
2018-10-17 00:09:29 +11:00
|
|
|
hidePostStatsLocal: typeof this.$store.state.config.hidePostStats == 'undefined'
|
|
|
|
? this.$store.state.instance.hidePostStats
|
|
|
|
: this.$store.state.config.hidePostStats,
|
2017-03-09 15:45:40 +11:00
|
|
|
animated: false
|
|
|
|
}
|
|
|
|
},
|
2016-10-31 02:12:35 +11:00
|
|
|
methods: {
|
|
|
|
favorite () {
|
|
|
|
if (!this.status.favorited) {
|
2016-11-08 01:04:27 +11:00
|
|
|
this.$store.dispatch('favorite', {id: this.status.id})
|
2016-10-31 02:12:35 +11:00
|
|
|
} else {
|
2016-11-08 01:04:27 +11:00
|
|
|
this.$store.dispatch('unfavorite', {id: this.status.id})
|
2016-10-31 02:12:35 +11:00
|
|
|
}
|
2017-03-09 15:45:40 +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,
|
2017-03-09 15:45:40 +11:00
|
|
|
'icon-star': this.status.favorited,
|
|
|
|
'animate-spin': this.animated
|
2016-10-31 02:12:35 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default FavoriteButton
|