pleroma-fe/src/components/retweet_button/retweet_button.js

69 lines
1.4 KiB
JavaScript
Raw Normal View History

2022-02-09 21:49:39 +01:00
import ConfirmModal from '../confirm_modal/confirm_modal.vue'
import { library } from '@fortawesome/fontawesome-svg-core'
import {
faRetweet,
faPlus,
faMinus,
faCheck
} from '@fortawesome/free-solid-svg-icons'
library.add(
faRetweet,
faPlus,
faMinus,
faCheck
)
const RetweetButton = {
2018-08-09 18:46:18 +02:00
props: ['status', 'loggedIn', 'visibility'],
2022-02-09 21:49:39 +01:00
components: {
ConfirmModal
},
data () {
return {
2022-02-09 21:49:39 +01:00
animated: false,
showingConfirmDialog: false
}
},
methods: {
retweet () {
2022-02-09 21:49:39 +01:00
if (!this.status.repeated && this.shouldConfirmRepeat) {
this.showConfirmDialog()
} else {
this.doRetweet()
}
},
doRetweet () {
2016-11-13 17:09:16 +01:00
if (!this.status.repeated) {
2019-07-05 09:02:14 +02:00
this.$store.dispatch('retweet', { id: this.status.id })
2018-06-14 11:00:11 +02:00
} else {
2019-07-05 09:02:14 +02:00
this.$store.dispatch('unretweet', { id: this.status.id })
2016-11-13 17:09:16 +01:00
}
this.animated = true
setTimeout(() => {
this.animated = false
}, 500)
2022-02-09 21:49:39 +01:00
this.hideConfirmDialog()
},
showConfirmDialog () {
this.showingConfirmDialog = true
},
hideConfirmDialog () {
this.showingConfirmDialog = false
}
},
computed: {
2020-09-29 12:18:37 +02:00
mergedConfig () {
return this.$store.getters.mergedConfig
},
remoteInteractionLink () {
return this.$store.getters.remoteInteractionLink({ statusId: this.status.id })
2022-02-09 21:49:39 +01:00
},
shouldConfirmRepeat () {
return this.mergedConfig.modalOnRepeat
2020-09-29 12:18:37 +02:00
}
}
}
export default RetweetButton