2019-09-29 19:33:15 +00:00
|
|
|
import { mapGetters } from 'vuex'
|
2020-10-19 16:38:49 +00:00
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
|
|
|
import { faStar } from '@fortawesome/free-solid-svg-icons'
|
|
|
|
import {
|
|
|
|
faStar as faStarRegular
|
|
|
|
} from '@fortawesome/free-regular-svg-icons'
|
|
|
|
|
|
|
|
library.add(
|
|
|
|
faStar,
|
|
|
|
faStarRegular
|
|
|
|
)
|
2019-09-29 19:33:15 +00:00
|
|
|
|
2016-10-30 15:12:35 +00:00
|
|
|
const FavoriteButton = {
|
2018-02-01 22:45:29 +00:00
|
|
|
props: ['status', 'loggedIn'],
|
2017-03-09 04:45:40 +00:00
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
animated: false
|
|
|
|
}
|
|
|
|
},
|
2016-10-30 15:12:35 +00:00
|
|
|
methods: {
|
|
|
|
favorite () {
|
|
|
|
if (!this.status.favorited) {
|
2019-07-05 07:02:14 +00:00
|
|
|
this.$store.dispatch('favorite', { id: this.status.id })
|
2016-10-30 15:12:35 +00:00
|
|
|
} else {
|
2019-07-05 07:02:14 +00:00
|
|
|
this.$store.dispatch('unfavorite', { id: this.status.id })
|
2016-10-30 15:12:35 +00:00
|
|
|
}
|
2017-03-09 04:45:40 +00:00
|
|
|
this.animated = true
|
|
|
|
setTimeout(() => {
|
|
|
|
this.animated = false
|
|
|
|
}, 500)
|
2016-10-30 15:12:35 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
classes () {
|
|
|
|
return {
|
2020-10-19 16:38:49 +00:00
|
|
|
'-favorited': this.status.favorited
|
2016-10-30 15:12:35 +00:00
|
|
|
}
|
2019-09-29 19:33:15 +00:00
|
|
|
},
|
|
|
|
...mapGetters(['mergedConfig'])
|
2016-10-30 15:12:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default FavoriteButton
|