yandere_fe/src/components/favorite_button/favorite_button.js

39 lines
808 B
JavaScript
Raw Normal View History

import { mapGetters } from 'vuex'
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
)
2016-10-30 08:12:35 -07:00
const FavoriteButton = {
props: ['status', 'loggedIn'],
data () {
return {
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
}
this.animated = true
setTimeout(() => {
this.animated = false
}, 500)
2016-10-30 08:12:35 -07:00
}
},
computed: {
...mapGetters(['mergedConfig'])
2016-10-30 08:12:35 -07:00
}
}
export default FavoriteButton