2020-02-28 16:39:47 +00:00
|
|
|
import Popover from '../popover/popover.vue'
|
|
|
|
|
2019-04-12 19:35:29 +00:00
|
|
|
const ExtraButtons = {
|
|
|
|
props: [ 'status' ],
|
2020-02-28 16:39:47 +00:00
|
|
|
components: { Popover },
|
2020-03-30 17:39:28 +00:00
|
|
|
data: function () {
|
|
|
|
return {
|
2020-05-07 21:33:21 +00:00
|
|
|
statusLink: `${this.$store.state.instance.server}${this.$router.resolve({ name: 'conversation', params: { id: this.status.id } }).href}`
|
2020-03-30 17:39:28 +00:00
|
|
|
}
|
|
|
|
},
|
2019-04-12 19:35:29 +00:00
|
|
|
methods: {
|
|
|
|
deleteStatus () {
|
|
|
|
const confirmed = window.confirm(this.$t('status.delete_confirm'))
|
|
|
|
if (confirmed) {
|
|
|
|
this.$store.dispatch('deleteStatus', { id: this.status.id })
|
|
|
|
}
|
|
|
|
},
|
|
|
|
pinStatus () {
|
2019-04-24 20:19:27 +00:00
|
|
|
this.$store.dispatch('pinStatus', this.status.id)
|
2019-04-27 13:36:10 +00:00
|
|
|
.then(() => this.$emit('onSuccess'))
|
2019-04-24 20:19:27 +00:00
|
|
|
.catch(err => this.$emit('onError', err.error.error))
|
2019-04-12 19:35:29 +00:00
|
|
|
},
|
|
|
|
unpinStatus () {
|
2019-04-24 19:34:30 +00:00
|
|
|
this.$store.dispatch('unpinStatus', this.status.id)
|
2019-04-27 13:36:10 +00:00
|
|
|
.then(() => this.$emit('onSuccess'))
|
|
|
|
.catch(err => this.$emit('onError', err.error.error))
|
2019-04-15 02:27:16 +00:00
|
|
|
},
|
2019-07-07 20:02:09 +00:00
|
|
|
muteConversation () {
|
|
|
|
this.$store.dispatch('muteConversation', this.status.id)
|
|
|
|
.then(() => this.$emit('onSuccess'))
|
|
|
|
.catch(err => this.$emit('onError', err.error.error))
|
|
|
|
},
|
|
|
|
unmuteConversation () {
|
|
|
|
this.$store.dispatch('unmuteConversation', this.status.id)
|
|
|
|
.then(() => this.$emit('onSuccess'))
|
|
|
|
.catch(err => this.$emit('onError', err.error.error))
|
2020-03-30 17:39:28 +00:00
|
|
|
},
|
|
|
|
copyLink () {
|
|
|
|
navigator.clipboard.writeText(this.statusLink)
|
|
|
|
.then(() => this.$emit('onSuccess'))
|
|
|
|
.catch(err => this.$emit('onError', err.error.error))
|
2019-04-12 19:35:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
currentUser () { return this.$store.state.users.currentUser },
|
|
|
|
canDelete () {
|
|
|
|
if (!this.currentUser) { return }
|
|
|
|
const superuser = this.currentUser.rights.moderator || this.currentUser.rights.admin
|
|
|
|
return superuser || this.status.user.id === this.currentUser.id
|
|
|
|
},
|
|
|
|
ownStatus () {
|
|
|
|
return this.status.user.id === this.currentUser.id
|
2019-04-14 17:18:56 +00:00
|
|
|
},
|
|
|
|
canPin () {
|
|
|
|
return this.ownStatus && (this.status.visibility === 'public' || this.status.visibility === 'unlisted')
|
2019-08-20 20:55:42 +00:00
|
|
|
},
|
|
|
|
canMute () {
|
|
|
|
return !!this.currentUser
|
2019-04-12 19:35:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ExtraButtons
|