2022-08-26 11:58:33 +00:00
|
|
|
import ConfirmModal from '../confirm_modal/confirm_modal.vue'
|
2020-10-19 16:38:49 +00:00
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
|
|
|
import { faRetweet } from '@fortawesome/free-solid-svg-icons'
|
|
|
|
|
|
|
|
library.add(faRetweet)
|
2019-09-29 19:33:15 +00:00
|
|
|
|
2016-11-13 15:42:56 +00:00
|
|
|
const RetweetButton = {
|
2018-08-09 16:46:18 +00:00
|
|
|
props: ['status', 'loggedIn', 'visibility'],
|
2022-08-26 11:58:33 +00:00
|
|
|
components: {
|
|
|
|
ConfirmModal
|
|
|
|
},
|
2017-03-09 04:45:40 +00:00
|
|
|
data () {
|
|
|
|
return {
|
2022-08-26 11:58:33 +00:00
|
|
|
animated: false,
|
|
|
|
showingConfirmDialog: false
|
2017-03-09 04:45:40 +00:00
|
|
|
}
|
|
|
|
},
|
2016-11-13 15:42:56 +00:00
|
|
|
methods: {
|
|
|
|
retweet () {
|
2022-08-26 11:58:33 +00:00
|
|
|
if (!this.status.repeated && this.shouldConfirmRepeat) {
|
|
|
|
this.showConfirmDialog()
|
|
|
|
} else {
|
|
|
|
this.doRetweet()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
doRetweet () {
|
2016-11-13 16:09:16 +00:00
|
|
|
if (!this.status.repeated) {
|
2019-07-05 07:02:14 +00:00
|
|
|
this.$store.dispatch('retweet', { id: this.status.id })
|
2018-06-14 09:00:11 +00:00
|
|
|
} else {
|
2019-07-05 07:02:14 +00:00
|
|
|
this.$store.dispatch('unretweet', { id: this.status.id })
|
2016-11-13 16:09:16 +00:00
|
|
|
}
|
2017-03-09 04:45:40 +00:00
|
|
|
this.animated = true
|
|
|
|
setTimeout(() => {
|
|
|
|
this.animated = false
|
|
|
|
}, 500)
|
2022-08-26 11:58:33 +00:00
|
|
|
this.hideConfirmDialog()
|
|
|
|
},
|
|
|
|
showConfirmDialog () {
|
|
|
|
this.showingConfirmDialog = true
|
|
|
|
},
|
|
|
|
hideConfirmDialog () {
|
|
|
|
this.showingConfirmDialog = false
|
2016-11-13 15:42:56 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2022-04-05 12:34:27 +00:00
|
|
|
isOwn () {
|
|
|
|
return this.status.user.id === this.$store.state.users.currentUser.id
|
|
|
|
},
|
2020-09-29 10:18:37 +00:00
|
|
|
mergedConfig () {
|
|
|
|
return this.$store.getters.mergedConfig
|
2022-08-26 11:58:33 +00:00
|
|
|
},
|
|
|
|
shouldConfirmRepeat () {
|
|
|
|
return this.mergedConfig.modalOnRepeat
|
2022-09-19 17:39:21 +00:00
|
|
|
},
|
|
|
|
remoteInteractionLink () {
|
|
|
|
return this.$store.getters.remoteInteractionLink({ statusId: this.status.id })
|
2020-09-29 10:18:37 +00:00
|
|
|
}
|
2016-11-13 15:42:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default RetweetButton
|