2020-02-28 16:39:47 +00:00
|
|
|
import Popover from '../popover/popover.vue'
|
2022-02-09 20:04:53 +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'
|
2020-10-19 19:35:46 +00:00
|
|
|
import {
|
|
|
|
faEllipsisH,
|
|
|
|
faBookmark,
|
|
|
|
faEyeSlash,
|
|
|
|
faThumbtack,
|
2020-12-03 09:57:17 +00:00
|
|
|
faShareAlt,
|
2022-06-21 04:52:08 +00:00
|
|
|
faExternalLinkAlt,
|
2022-08-23 01:08:58 +00:00
|
|
|
faHistory,
|
2022-01-16 06:01:19 +00:00
|
|
|
faPlus,
|
|
|
|
faTimes
|
2020-10-19 19:35:46 +00:00
|
|
|
} from '@fortawesome/free-solid-svg-icons'
|
|
|
|
import {
|
2021-01-12 12:43:21 +00:00
|
|
|
faBookmark as faBookmarkReg,
|
|
|
|
faFlag
|
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,
|
2021-01-12 12:43:21 +00:00
|
|
|
faExternalLinkAlt,
|
2022-06-21 04:52:08 +00:00
|
|
|
faFlag,
|
2022-08-23 01:08:58 +00:00
|
|
|
faHistory,
|
2022-01-16 06:01:19 +00:00
|
|
|
faPlus,
|
|
|
|
faTimes
|
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 = {
|
2022-07-31 09:35:48 +00:00
|
|
|
props: ['status'],
|
2022-02-09 20:04:53 +00:00
|
|
|
components: {
|
|
|
|
Popover,
|
|
|
|
ConfirmModal
|
|
|
|
},
|
2022-01-16 06:01:19 +00:00
|
|
|
data () {
|
|
|
|
return {
|
2022-02-09 20:04:53 +00:00
|
|
|
expanded: false,
|
|
|
|
showingDeleteDialog: false
|
2022-01-16 06:01:19 +00:00
|
|
|
}
|
|
|
|
},
|
2019-04-12 19:35:29 +00:00
|
|
|
methods: {
|
2022-01-16 06:01:19 +00:00
|
|
|
onShow () {
|
|
|
|
this.expanded = true
|
|
|
|
},
|
|
|
|
onClose () {
|
|
|
|
this.expanded = false
|
|
|
|
},
|
2019-04-12 19:35:29 +00:00
|
|
|
deleteStatus () {
|
2022-02-09 20:04:53 +00:00
|
|
|
if (this.shouldConfirmDelete) {
|
|
|
|
this.showDeleteStatusConfirmDialog()
|
|
|
|
} else {
|
|
|
|
this.doDeleteStatus()
|
2019-04-12 19:35:29 +00:00
|
|
|
}
|
|
|
|
},
|
2022-02-09 20:04:53 +00:00
|
|
|
doDeleteStatus () {
|
|
|
|
this.$store.dispatch('deleteStatus', { id: this.status.id })
|
|
|
|
hideDeleteStatusConfirmDialog()
|
|
|
|
},
|
|
|
|
showDeleteStatusConfirmDialog () {
|
|
|
|
this.showingDeleteDialog = true
|
|
|
|
},
|
|
|
|
hideDeleteStatusConfirmDialog () {
|
|
|
|
this.showingDeleteDialog = false
|
|
|
|
},
|
2019-04-12 19:35:29 +00:00
|
|
|
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))
|
2021-01-12 12:43:21 +00:00
|
|
|
},
|
|
|
|
reportStatus () {
|
|
|
|
this.$store.dispatch('openUserReportingModal', { userId: this.status.user.id, statusIds: [this.status.id] })
|
2022-06-08 03:31:48 +00:00
|
|
|
},
|
|
|
|
editStatus () {
|
|
|
|
this.$store.dispatch('fetchStatusSource', { id: this.status.id })
|
|
|
|
.then(data => this.$store.dispatch('openEditStatusModal', {
|
|
|
|
statusId: this.status.id,
|
|
|
|
subject: data.spoiler_text,
|
|
|
|
statusText: data.text,
|
|
|
|
statusIsSensitive: this.status.nsfw,
|
|
|
|
statusPoll: this.status.poll,
|
2022-06-11 22:38:03 +00:00
|
|
|
statusFiles: [...this.status.attachments],
|
2022-06-08 03:31:48 +00:00
|
|
|
visibility: this.status.visibility,
|
|
|
|
statusContentType: data.content_type
|
|
|
|
}))
|
2022-06-21 04:52:08 +00:00
|
|
|
},
|
|
|
|
showStatusHistory () {
|
2022-06-27 00:10:30 +00:00
|
|
|
const originalStatus = { ...this.status }
|
|
|
|
const stripFieldsList = ['attachments', 'created_at', 'emojis', 'text', 'raw_html', 'nsfw', 'poll', 'summary', 'summary_raw_html']
|
|
|
|
stripFieldsList.forEach(p => delete originalStatus[p])
|
2022-06-21 04:52:08 +00:00
|
|
|
this.$store.dispatch('openStatusHistoryModal', originalStatus)
|
2019-04-12 19:35:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
currentUser () { return this.$store.state.users.currentUser },
|
|
|
|
canDelete () {
|
|
|
|
if (!this.currentUser) { return }
|
2022-08-06 12:00:29 +00:00
|
|
|
return this.currentUser.privileges.includes('messages_delete') || this.status.user.id === this.currentUser.id
|
2019-04-12 19:35:29 +00:00
|
|
|
},
|
|
|
|
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
|
|
|
},
|
2022-06-20 22:24:50 +00:00
|
|
|
canBookmark () {
|
|
|
|
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}`
|
2022-06-21 04:52:08 +00:00
|
|
|
},
|
|
|
|
isEdited () {
|
|
|
|
return this.status.edited_at !== null
|
2022-06-21 23:44:04 +00:00
|
|
|
},
|
2022-02-09 20:04:53 +00:00
|
|
|
editingAvailable () { return this.$store.state.instance.editingAvailable },
|
|
|
|
shouldConfirmDelete () {
|
|
|
|
return this.$store.getters.mergedConfig.modalOnDelete
|
|
|
|
}
|
2019-04-12 19:35:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ExtraButtons
|