akkoma-fe/src/components/retweet_button/retweet_button.js
eris cb7c816980
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
New option: Confirm repeats
2022-08-25 05:32:40 +00:00

51 lines
1.3 KiB
JavaScript

import { library } from '@fortawesome/fontawesome-svg-core'
import { faRetweet } from '@fortawesome/free-solid-svg-icons'
library.add(faRetweet)
const RetweetButton = {
props: ['status', 'loggedIn', 'visibility'],
data () {
return {
animated: false
}
},
methods: {
retweet () {
if (this.mergedConfig.confirmRepeats) {
if (!this.status.repeated) {
const confirmed = window.confirm(this.$t('status.repeat_confirm'))
if (confirmed) {
this.$store.dispatch('retweet', { id: this.status.id })
}
} else {
const confirmed = window.confirm(this.$t('status.unrepeat_confirm'))
if (confirmed) {
this.$store.dispatch('unretweet', { id: this.status.id })
}
}
} else {
if (!this.status.repeated) {
this.$store.dispatch('retweet', { id: this.status.id })
} else {
this.$store.dispatch('unretweet', { id: this.status.id })
}
}
this.animated = true
setTimeout(() => {
this.animated = false
}, 500)
}
},
computed: {
isOwn () {
return this.status.user.id === this.$store.state.users.currentUser.id
},
mergedConfig () {
return this.$store.getters.mergedConfig
}
}
}
export default RetweetButton