2020-02-28 16:39:47 +00:00
|
|
|
import Popover from '../popover/popover.vue'
|
2020-10-19 16:38:49 +00:00
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
2020-10-19 19:35:46 +00:00
|
|
|
import {
|
|
|
|
faEllipsisH,
|
|
|
|
faBookmark,
|
|
|
|
faEyeSlash,
|
|
|
|
faThumbtack,
|
2020-12-03 09:57:17 +00:00
|
|
|
faShareAlt,
|
|
|
|
faExternalLinkAlt
|
2020-10-19 19:35:46 +00:00
|
|
|
} from '@fortawesome/free-solid-svg-icons'
|
|
|
|
import {
|
2020-10-20 21:31:16 +00:00
|
|
|
faBookmark as faBookmarkReg
|
2020-10-19 19:35:46 +00:00
|
|
|
} from '@fortawesome/free-regular-svg-icons'
|
2020-10-19 16:38:49 +00:00
|
|
|
|
2020-10-19 19:35:46 +00:00
|
|
|
library.add(
|
|
|
|
faEllipsisH,
|
|
|
|
faBookmark,
|
|
|
|
faBookmarkReg,
|
|
|
|
faEyeSlash,
|
|
|
|
faThumbtack,
|
2020-12-03 09:57:17 +00:00
|
|
|
faShareAlt,
|
|
|
|
faExternalLinkAlt
|
2020-10-19 19:35:46 +00:00
|
|
|
)
|
2020-02-28 16:39:47 +00:00
|
|
|
|
2019-04-12 19:35:29 +00:00
|
|
|
const ExtraButtons = {
|
|
|
|
props: [ 'status' ],
|
2020-02-28 16:39:47 +00:00
|
|
|
components: { Popover },
|
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))
|
2020-07-03 19:45:49 +00: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-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
|
2020-05-08 07:46:00 +00:00
|
|
|
},
|
|
|
|
statusLink () {
|
|
|
|
return `${this.$store.state.instance.server}${this.$router.resolve({ name: 'conversation', params: { id: this.status.id } }).href}`
|
2019-04-12 19:35:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ExtraButtons
|