2018-04-05 06:45:19 +02:00
|
|
|
<ModalDialog
|
2018-05-02 02:05:36 +02:00
|
|
|
{id}
|
|
|
|
{label}
|
|
|
|
{title}
|
2018-04-05 06:45:19 +02:00
|
|
|
background="var(--main-bg)"
|
|
|
|
>
|
2018-05-02 02:05:36 +02:00
|
|
|
<GenericDialogList {items} on:click="onClick(event)"/>
|
2018-04-05 06:45:19 +02:00
|
|
|
</ModalDialog>
|
|
|
|
<script>
|
|
|
|
import ModalDialog from './ModalDialog.html'
|
2018-04-09 01:56:20 +02:00
|
|
|
import { store } from '../../../_store/store'
|
2018-04-05 06:45:19 +02:00
|
|
|
import GenericDialogList from './GenericDialogList.html'
|
2018-05-13 00:00:11 +02:00
|
|
|
import { importShowComposeDialog, importShowCopyDialog } from '../asyncDialogs'
|
2018-04-09 01:56:20 +02:00
|
|
|
import { createDialogId } from '../helpers/createDialogId'
|
|
|
|
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'
|
|
|
|
import { setAccountFollowed } from '../../../_actions/follow'
|
2018-04-05 06:45:19 +02:00
|
|
|
|
|
|
|
export default {
|
2018-04-09 01:56:20 +02:00
|
|
|
oncreate,
|
|
|
|
store: () => store,
|
|
|
|
data: () => ({
|
|
|
|
id: createDialogId()
|
|
|
|
}),
|
2018-04-05 06:45:19 +02:00
|
|
|
computed: {
|
2018-05-13 00:00:11 +02:00
|
|
|
//
|
|
|
|
// begin copypasta (StatusOptionsDialog.html / AccountProfileOptionsDialog.html)
|
|
|
|
//
|
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-15 07:18:48 +02:00
|
|
|
if (typeof following === 'undefined' || !account) {
|
|
|
|
return ''
|
|
|
|
}
|
|
|
|
return (following || followRequested)
|
|
|
|
? `Unfollow @${acct}`
|
|
|
|
: `Follow @${acct}`
|
|
|
|
},
|
2018-05-13 00:00:11 +02:00
|
|
|
followIcon: ({ following, followRequested }) => (
|
|
|
|
following ? '#fa-user-times' : followRequested ? '#fa-hourglass' : '#fa-user-plus'
|
|
|
|
),
|
|
|
|
blockLabel: ({ blocking, acct }) => (
|
|
|
|
blocking ? `Unblock @${acct}` : `Block @${acct}`
|
|
|
|
),
|
2018-05-02 02:05:36 +02:00
|
|
|
blockIcon: ({ blocking }) => blocking ? '#fa-unlock' : '#fa-ban',
|
2018-05-13 00:00:11 +02:00
|
|
|
muteLabel: ({ muting, acct }) => (
|
|
|
|
muting ? `Unmute @${acct}` : `Mute @${acct}`
|
|
|
|
),
|
2018-05-02 02:05:36 +02:00
|
|
|
muteIcon: ({ muting }) => muting ? '#fa-volume-up' : '#fa-volume-off',
|
2018-05-13 00:00:11 +02:00
|
|
|
isUser: ({ accountId, verifyCredentialsId }) => accountId === verifyCredentialsId,
|
|
|
|
//
|
|
|
|
// end copypasta (StatusOptionsDialog.html / AccountProfileOptionsDialog.html)
|
|
|
|
//
|
|
|
|
items: ({
|
|
|
|
blockLabel, blocking, blockIcon, muteLabel, muteIcon,
|
2018-04-20 06:38:01 +02:00
|
|
|
followLabel, followIcon, following, followRequested,
|
2018-05-13 00:00:11 +02:00
|
|
|
accountId, verifyCredentialsId, acct, isUser
|
|
|
|
}) => ([
|
|
|
|
!isUser && {
|
|
|
|
key: 'mention',
|
|
|
|
label: `Mention @${acct}`,
|
|
|
|
icon: '#fa-comments'
|
|
|
|
},
|
|
|
|
!isUser && !blocking && {
|
|
|
|
key: 'follow',
|
|
|
|
label: followLabel,
|
|
|
|
icon: followIcon
|
|
|
|
},
|
|
|
|
!isUser && {
|
|
|
|
key: 'block',
|
|
|
|
label: blockLabel,
|
|
|
|
icon: blockIcon
|
|
|
|
},
|
|
|
|
!isUser && !blocking && {
|
|
|
|
key: 'mute',
|
|
|
|
label: muteLabel,
|
|
|
|
icon: muteIcon
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'copy',
|
|
|
|
label: 'Copy link to account',
|
2018-05-27 02:23:27 +02:00
|
|
|
icon: '#fa-link'
|
2018-05-13 00:00:11 +02:00
|
|
|
}
|
|
|
|
].filter(Boolean))
|
2018-04-05 06:45:19 +02:00
|
|
|
},
|
|
|
|
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 'mention':
|
|
|
|
return this.onMentionClicked()
|
2018-04-15 07:18:48 +02:00
|
|
|
case 'follow':
|
|
|
|
return this.onFollowClicked()
|
2018-04-15 03:47:55 +02:00
|
|
|
case 'block':
|
|
|
|
return this.onBlockClicked()
|
2018-04-15 07:18:48 +02:00
|
|
|
case 'mute':
|
|
|
|
return this.onMuteClicked()
|
2018-05-13 00:00:11 +02:00
|
|
|
case 'copy':
|
|
|
|
return this.onCopyClicked()
|
2018-04-15 03:47:55 +02:00
|
|
|
}
|
|
|
|
},
|
2018-04-20 06:38:01 +02:00
|
|
|
async onMentionClicked () {
|
2018-04-19 18:37:05 +02:00
|
|
|
let { acct } = this.get()
|
2018-04-07 09:21:00 +02:00
|
|
|
this.store.setComposeData('dialog', {
|
2018-04-15 07:18:48 +02:00
|
|
|
text: `@${acct} `
|
2018-04-05 06:45:19 +02:00
|
|
|
})
|
2018-04-21 18:56:53 +02:00
|
|
|
let showComposeDialog = await importShowComposeDialog()
|
|
|
|
showComposeDialog()
|
2018-04-09 01:56:20 +02:00
|
|
|
this.close()
|
2018-04-15 03:47:55 +02:00
|
|
|
},
|
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 07:18:48 +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-05-13 00:00:11 +02:00
|
|
|
},
|
|
|
|
async onCopyClicked () {
|
|
|
|
let { account } = this.get()
|
|
|
|
let { url } = account
|
|
|
|
let showCopyDialog = await importShowCopyDialog()
|
|
|
|
showCopyDialog(url)
|
2018-04-05 06:45:19 +02:00
|
|
|
}
|
2018-04-09 01:56:20 +02:00
|
|
|
},
|
|
|
|
components: {
|
|
|
|
ModalDialog,
|
|
|
|
GenericDialogList
|
2018-04-20 06:38:01 +02:00
|
|
|
}
|
2018-04-05 06:45:19 +02:00
|
|
|
}
|
|
|
|
</script>
|