2018-04-05 05:33:17 +02:00
|
|
|
<ModalDialog
|
2018-05-02 02:05:36 +02:00
|
|
|
{id}
|
|
|
|
{label}
|
|
|
|
{title}
|
2018-04-05 05:33:17 +02:00
|
|
|
background="var(--main-bg)"
|
|
|
|
>
|
2018-05-02 02:05:36 +02:00
|
|
|
<GenericDialogList {items} on:click="onClick(event)"/>
|
2018-03-12 03:40:32 +01:00
|
|
|
</ModalDialog>
|
|
|
|
<script>
|
|
|
|
import ModalDialog from './ModalDialog.html'
|
2018-04-09 01:56:20 +02:00
|
|
|
import { store } from '../../../_store/store'
|
2018-03-12 03:40:32 +01:00
|
|
|
import GenericDialogList from './GenericDialogList.html'
|
2018-04-09 01:56:20 +02:00
|
|
|
import { setAccountFollowed } from '../../../_actions/follow'
|
|
|
|
import { doDeleteStatus } from '../../../_actions/delete'
|
|
|
|
import { show } from '../helpers/showDialog'
|
|
|
|
import { close } from '../helpers/closeDialog'
|
|
|
|
import { oncreate } from '../helpers/onCreateDialog'
|
2018-04-15 03:47:55 +02:00
|
|
|
import { setAccountBlocked } from '../../../_actions/block'
|
2018-04-15 07:18:48 +02:00
|
|
|
import { setAccountMuted } from '../../../_actions/mute'
|
2018-04-29 21:28:44 +02:00
|
|
|
import { setStatusPinnedOrUnpinned } from '../../../_actions/pin'
|
2018-03-12 03:40:32 +01:00
|
|
|
|
|
|
|
export default {
|
2018-04-09 01:56:20 +02:00
|
|
|
oncreate,
|
2018-03-12 03:40:32 +01:00
|
|
|
computed: {
|
2018-05-02 02:05:36 +02:00
|
|
|
relationship: ({ $currentAccountRelationship }) => $currentAccountRelationship,
|
|
|
|
account: ({ $currentAccountProfile }) => $currentAccountProfile,
|
|
|
|
verifyCredentials: ({ $currentVerifyCredentials }) => $currentVerifyCredentials,
|
|
|
|
statusId: ({ status }) => status.id,
|
|
|
|
pinned: ({ status }) => status.pinned,
|
2018-04-15 07:18:48 +02:00
|
|
|
// begin account data copypasta
|
2018-05-02 02:05:36 +02:00
|
|
|
verifyCredentialsId: ({ verifyCredentials }) => verifyCredentials.id,
|
|
|
|
following: ({ relationship }) => relationship && relationship.following,
|
|
|
|
followRequested: ({ relationship }) => relationship && relationship.requested,
|
|
|
|
accountId: ({ account }) => account && account.id,
|
|
|
|
acct: ({ account }) => account.acct,
|
|
|
|
muting: ({ relationship }) => relationship.muting,
|
|
|
|
blocking: ({ relationship }) => relationship.blocking,
|
|
|
|
followLabel: ({ following, followRequested, account, acct }) => {
|
2018-04-05 16:44:10 +02:00
|
|
|
if (typeof following === 'undefined' || !account) {
|
2018-03-12 03:40:32 +01:00
|
|
|
return ''
|
|
|
|
}
|
2018-03-15 06:14:06 +01:00
|
|
|
return (following || followRequested)
|
2018-04-15 07:18:48 +02:00
|
|
|
? `Unfollow @${acct}`
|
|
|
|
: `Follow @${acct}`
|
2018-03-12 03:40:32 +01:00
|
|
|
},
|
2018-05-02 02:05:36 +02:00
|
|
|
followIcon: ({ following, followRequested }) => {
|
2018-04-15 07:18:48 +02:00
|
|
|
return following ? '#fa-user-times' : followRequested ? '#fa-hourglass' : '#fa-user-plus'
|
2018-04-15 03:47:55 +02:00
|
|
|
},
|
2018-05-02 02:05:36 +02:00
|
|
|
blockLabel: ({ blocking, acct }) => {
|
2018-04-15 07:18:48 +02:00
|
|
|
return blocking ? `Unblock @${acct}` : `Block @${acct}`
|
|
|
|
},
|
2018-05-02 02:05:36 +02:00
|
|
|
blockIcon: ({ blocking }) => blocking ? '#fa-unlock' : '#fa-ban',
|
|
|
|
muteLabel: ({ muting, acct }) => {
|
2018-04-15 07:18:48 +02:00
|
|
|
return muting ? `Unmute @${acct}` : `Mute @${acct}`
|
|
|
|
},
|
2018-05-02 02:05:36 +02:00
|
|
|
muteIcon: ({ muting }) => muting ? '#fa-volume-up' : '#fa-volume-off',
|
2018-04-15 07:18:48 +02:00
|
|
|
// end account data copypasta
|
2018-05-02 02:05:36 +02:00
|
|
|
isUser: ({ accountId, verifyCredentialsId }) => accountId === verifyCredentialsId,
|
|
|
|
pinLabel: ({ pinned, isUser }) => isUser ? (pinned ? 'Unpin from profile' : 'Pin to profile') : '',
|
|
|
|
items: ({ blockLabel, blocking, blockIcon, muteLabel, muteIcon, followLabel, followIcon,
|
|
|
|
following, followRequested, pinLabel, isUser }) => {
|
2018-04-15 07:18:48 +02:00
|
|
|
return [
|
|
|
|
isUser && {
|
2018-04-15 03:47:55 +02:00
|
|
|
key: 'delete',
|
|
|
|
label: 'Delete',
|
|
|
|
icon: '#fa-trash'
|
|
|
|
},
|
2018-04-29 21:28:44 +02:00
|
|
|
isUser && {
|
|
|
|
key: 'pin',
|
|
|
|
label: pinLabel,
|
|
|
|
icon: '#fa-thumb-tack'
|
|
|
|
},
|
2018-04-15 07:18:48 +02:00
|
|
|
!isUser && !blocking && {
|
2018-03-12 03:40:32 +01:00
|
|
|
key: 'follow',
|
|
|
|
label: followLabel,
|
2018-04-15 07:18:48 +02:00
|
|
|
icon: followIcon
|
2018-03-14 16:36:12 +01:00
|
|
|
},
|
2018-04-15 07:18:48 +02:00
|
|
|
!isUser && {
|
2018-04-15 03:47:55 +02:00
|
|
|
key: 'block',
|
|
|
|
label: blockLabel,
|
2018-04-15 07:18:48 +02:00
|
|
|
icon: blockIcon
|
|
|
|
},
|
|
|
|
!isUser && !blocking && {
|
|
|
|
key: 'mute',
|
|
|
|
label: muteLabel,
|
|
|
|
icon: muteIcon
|
2018-03-12 03:40:32 +01:00
|
|
|
}
|
2018-04-15 07:18:48 +02:00
|
|
|
|
2018-03-14 16:36:12 +01:00
|
|
|
].filter(Boolean)
|
2018-04-15 07:18:48 +02:00
|
|
|
}
|
2018-03-12 03:40:32 +01:00
|
|
|
},
|
|
|
|
components: {
|
|
|
|
ModalDialog,
|
|
|
|
GenericDialogList
|
|
|
|
},
|
|
|
|
store: () => store,
|
|
|
|
methods: {
|
2018-04-09 01:56:20 +02:00
|
|
|
show,
|
|
|
|
close,
|
2018-04-20 06:38:01 +02:00
|
|
|
onClick (item) {
|
2018-04-15 03:47:55 +02:00
|
|
|
switch (item.key) {
|
|
|
|
case 'delete':
|
|
|
|
return this.onDeleteClicked()
|
2018-04-29 21:28:44 +02:00
|
|
|
case 'pin':
|
|
|
|
return this.onPinClicked()
|
2018-04-15 03:47:55 +02:00
|
|
|
case 'follow':
|
|
|
|
return this.onFollowClicked()
|
|
|
|
case 'block':
|
|
|
|
return this.onBlockClicked()
|
2018-04-15 07:18:48 +02:00
|
|
|
case 'mute':
|
|
|
|
return this.onMuteClicked()
|
2018-03-12 03:40:32 +01:00
|
|
|
}
|
2018-04-15 03:47:55 +02:00
|
|
|
},
|
2018-04-20 06:38:01 +02:00
|
|
|
async onDeleteClicked () {
|
2018-04-19 18:37:05 +02:00
|
|
|
let { statusId } = this.get()
|
2018-04-15 03:47:55 +02:00
|
|
|
this.close()
|
|
|
|
await doDeleteStatus(statusId)
|
|
|
|
},
|
2018-04-29 21:28:44 +02:00
|
|
|
async onPinClicked () {
|
|
|
|
let { statusId, pinned } = this.get()
|
|
|
|
this.close()
|
|
|
|
await setStatusPinnedOrUnpinned(statusId, !pinned, true)
|
|
|
|
},
|
2018-04-20 06:38:01 +02:00
|
|
|
async onFollowClicked () {
|
2018-04-19 18:37:05 +02:00
|
|
|
let { accountId, following } = this.get()
|
2018-04-15 03:47:55 +02:00
|
|
|
this.close()
|
|
|
|
await setAccountFollowed(accountId, !following, true)
|
|
|
|
},
|
2018-04-20 06:38:01 +02:00
|
|
|
async onBlockClicked () {
|
2018-04-19 18:37:05 +02:00
|
|
|
let { accountId, blocking } = this.get()
|
2018-04-15 03:47:55 +02:00
|
|
|
this.close()
|
|
|
|
await setAccountBlocked(accountId, !blocking, true)
|
2018-04-15 07:18:48 +02:00
|
|
|
},
|
2018-04-20 06:38:01 +02:00
|
|
|
async onMuteClicked () {
|
2018-04-19 18:37:05 +02:00
|
|
|
let { accountId, muting } = this.get()
|
2018-04-15 07:18:48 +02:00
|
|
|
this.close()
|
|
|
|
await setAccountMuted(accountId, !muting, true)
|
2018-03-12 03:40:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|