2020-02-29 03:39:47 +11:00
|
|
|
import Popover from '../popover/popover.vue'
|
2020-10-20 03:38:49 +11:00
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
2020-10-20 06:35:46 +11:00
|
|
|
import {
|
|
|
|
faEllipsisH,
|
|
|
|
faBookmark,
|
|
|
|
faEyeSlash,
|
|
|
|
faThumbtack,
|
|
|
|
faShareAlt
|
|
|
|
} from '@fortawesome/free-solid-svg-icons'
|
|
|
|
import {
|
2020-10-21 08:31:16 +11:00
|
|
|
faBookmark as faBookmarkReg
|
2020-10-20 06:35:46 +11:00
|
|
|
} from '@fortawesome/free-regular-svg-icons'
|
2020-10-20 03:38:49 +11:00
|
|
|
|
2020-10-20 06:35:46 +11:00
|
|
|
library.add(
|
|
|
|
faEllipsisH,
|
|
|
|
faBookmark,
|
|
|
|
faBookmarkReg,
|
|
|
|
faEyeSlash,
|
|
|
|
faThumbtack,
|
|
|
|
faShareAlt
|
|
|
|
)
|
2020-02-29 03:39:47 +11:00
|
|
|
|
2019-04-13 05:35:29 +10:00
|
|
|
const ExtraButtons = {
|
|
|
|
props: [ 'status' ],
|
2020-02-29 03:39:47 +11:00
|
|
|
components: { Popover },
|
2019-04-13 05:35:29 +10: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-25 06:19:27 +10:00
|
|
|
this.$store.dispatch('pinStatus', this.status.id)
|
2019-04-27 23:36:10 +10:00
|
|
|
.then(() => this.$emit('onSuccess'))
|
2019-04-25 06:19:27 +10:00
|
|
|
.catch(err => this.$emit('onError', err.error.error))
|
2019-04-13 05:35:29 +10:00
|
|
|
},
|
|
|
|
unpinStatus () {
|
2019-04-25 05:34:30 +10:00
|
|
|
this.$store.dispatch('unpinStatus', this.status.id)
|
2019-04-27 23:36:10 +10:00
|
|
|
.then(() => this.$emit('onSuccess'))
|
|
|
|
.catch(err => this.$emit('onError', err.error.error))
|
2019-04-15 12:27:16 +10:00
|
|
|
},
|
2019-07-08 06:02:09 +10: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-31 04:39:28 +11:00
|
|
|
},
|
|
|
|
copyLink () {
|
|
|
|
navigator.clipboard.writeText(this.statusLink)
|
|
|
|
.then(() => this.$emit('onSuccess'))
|
|
|
|
.catch(err => this.$emit('onError', err.error.error))
|
2020-07-04 05:45:49 +10:00
|
|
|
},
|
|
|
|
bookmarkStatus () {
|
|
|
|
this.$store.dispatch('bookmark', { id: this.status.id })
|
|
|
|
.then(() => this.$emit('onSuccess'))
|
|
|
|
.catch(err => this.$emit('onError', err.error.error))
|
|
|
|
},
|
|
|
|
unbookmarkStatus () {
|
|
|
|
this.$store.dispatch('unbookmark', { id: this.status.id })
|
|
|
|
.then(() => this.$emit('onSuccess'))
|
|
|
|
.catch(err => this.$emit('onError', err.error.error))
|
2019-04-13 05:35:29 +10: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-15 03:18:56 +10:00
|
|
|
},
|
|
|
|
canPin () {
|
|
|
|
return this.ownStatus && (this.status.visibility === 'public' || this.status.visibility === 'unlisted')
|
2019-08-21 06:55:42 +10:00
|
|
|
},
|
|
|
|
canMute () {
|
|
|
|
return !!this.currentUser
|
2020-05-08 17:46:00 +10:00
|
|
|
},
|
|
|
|
statusLink () {
|
|
|
|
return `${this.$store.state.instance.server}${this.$router.resolve({ name: 'conversation', params: { id: this.status.id } }).href}`
|
2019-04-13 05:35:29 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ExtraButtons
|