204 lines
6.8 KiB
HTML
204 lines
6.8 KiB
HTML
<ModalDialog
|
|
{id}
|
|
{label}
|
|
{title}
|
|
shrinkWidthToFit={true}
|
|
background="var(--main-bg)"
|
|
>
|
|
<GenericDialogList selectable={false} {items} on:click="onClick(event)"/>
|
|
</ModalDialog>
|
|
<script>
|
|
import ModalDialog from './ModalDialog.html'
|
|
import { store } from '../../../_store/store'
|
|
import GenericDialogList from './GenericDialogList.html'
|
|
import { show } from '../helpers/showDialog'
|
|
import { close } from '../helpers/closeDialog'
|
|
import { oncreate } from '../helpers/onCreateDialog'
|
|
import { setAccountBlocked } from '../../../_actions/block'
|
|
import { setAccountFollowed } from '../../../_actions/follow'
|
|
import { setShowReblogs } from '../../../_actions/setShowReblogs'
|
|
import { setDomainBlocked } from '../../../_actions/setDomainBlocked'
|
|
import { copyText } from '../../../_actions/copyText'
|
|
import { composeNewStatusMentioning } from '../../../_actions/mention'
|
|
import { toggleMute } from '../../../_actions/toggleMute'
|
|
import { reportStatusOrAccount } from '../../../_actions/report'
|
|
import { formatIntl } from '../../../_utils/formatIntl'
|
|
|
|
export default {
|
|
oncreate,
|
|
store: () => store,
|
|
computed: {
|
|
//
|
|
// begin copypasta (StatusOptionsDialog.html / AccountProfileOptionsDialog.html)
|
|
//
|
|
verifyCredentialsId: ({ verifyCredentials }) => verifyCredentials.id,
|
|
following: ({ relationship }) => relationship && relationship.following,
|
|
followRequested: ({ relationship }) => relationship && relationship.requested,
|
|
accountId: ({ account }) => account && account.id,
|
|
acct: ({ account }) => account.acct,
|
|
username: ({ account }) => account.username,
|
|
muting: ({ relationship }) => relationship && relationship.muting,
|
|
blocking: ({ relationship }) => relationship && relationship.blocking,
|
|
followLabel: ({ following, followRequested, account, username }) => {
|
|
if (typeof following === 'undefined' || !account) {
|
|
return ''
|
|
}
|
|
return (following || followRequested)
|
|
? formatIntl('intl.unfollowAccount', { account: `@${username}` })
|
|
: formatIntl('intl.followAccount', { account: `@${username}` })
|
|
},
|
|
followIcon: ({ following, followRequested }) => (
|
|
following ? '#fa-user-times' : followRequested ? '#fa-hourglass' : '#fa-user-plus'
|
|
),
|
|
blockLabel: ({ blocking, username }) => (
|
|
blocking
|
|
? formatIntl('intl.unblockAccount', { account: `@${username}` })
|
|
: formatIntl('intl.blockAccount', { account: `@${username}` })
|
|
),
|
|
blockIcon: ({ blocking }) => blocking ? '#fa-unlock' : '#fa-ban',
|
|
muteLabel: ({ muting, username }) => (
|
|
muting
|
|
? formatIntl('intl.unmuteAccount', { account: `@${username}` })
|
|
: formatIntl('intl.muteAccount', { account: `@${username}` })
|
|
),
|
|
muteIcon: ({ muting }) => muting ? '#fa-volume-up' : '#fa-volume-off',
|
|
isUser: ({ accountId, verifyCredentialsId }) => accountId === verifyCredentialsId,
|
|
//
|
|
// end copypasta (StatusOptionsDialog.html / AccountProfileOptionsDialog.html)
|
|
//
|
|
showingReblogs: ({ relationship }) => relationship ? relationship.showing_reblogs : true,
|
|
showReblogsLabel: ({ showingReblogs, username }) => (
|
|
showingReblogs
|
|
? formatIntl('intl.hideReblogsFromAccount', { account: `@${username}` })
|
|
: formatIntl('intl.showReblogsFromAccount', { account: `@${username}` })
|
|
),
|
|
domain: ({ acct }) => acct.split('@')[1],
|
|
blockingDomain: ({ relationship }) => relationship && relationship.domain_blocking,
|
|
blockDomainLabel: ({ blockingDomain, domain }) => (
|
|
blockingDomain
|
|
? formatIntl('intl.showDomain', { domain })
|
|
: formatIntl('intl.hideDomain', { domain })
|
|
),
|
|
reportLabel: ({ username }) => (
|
|
formatIntl('intl.reportAccount', { account: `@${username}` })
|
|
),
|
|
items: ({
|
|
blockLabel, blocking, blockIcon, muteLabel, muteIcon,
|
|
followLabel, followIcon, following, followRequested,
|
|
accountId, verifyCredentialsId, username, isUser, showReblogsLabel,
|
|
domain, blockDomainLabel, reportLabel
|
|
}) => ([
|
|
!isUser && {
|
|
key: 'mention',
|
|
label: formatIntl('intl.mentionAccount', { account: `@${username}` }),
|
|
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
|
|
},
|
|
!isUser && following && {
|
|
key: 'showReblogs',
|
|
label: showReblogsLabel,
|
|
icon: '#fa-retweet'
|
|
},
|
|
!isUser && domain && {
|
|
key: 'blockDomain',
|
|
label: blockDomainLabel,
|
|
icon: '#fa-ban'
|
|
},
|
|
!isUser && {
|
|
key: 'report',
|
|
label: reportLabel,
|
|
icon: '#fa-flag'
|
|
},
|
|
{
|
|
key: 'copy',
|
|
label: 'intl.copyLinkToAccount',
|
|
icon: '#fa-link'
|
|
}
|
|
].filter(Boolean))
|
|
},
|
|
methods: {
|
|
show,
|
|
close,
|
|
onClick (item) {
|
|
switch (item.key) {
|
|
case 'mention':
|
|
return this.onMentionClicked()
|
|
case 'follow':
|
|
return this.onFollowClicked()
|
|
case 'block':
|
|
return this.onBlockClicked()
|
|
case 'mute':
|
|
return this.onMuteClicked()
|
|
case 'showReblogs':
|
|
return this.onShowReblogsClicked()
|
|
case 'blockDomain':
|
|
return this.onBlockDomainClicked()
|
|
case 'copy':
|
|
return this.onCopyClicked()
|
|
case 'report':
|
|
return this.onReport()
|
|
}
|
|
},
|
|
async onMentionClicked () {
|
|
const { account } = this.get()
|
|
this.close()
|
|
await composeNewStatusMentioning(account)
|
|
},
|
|
async onFollowClicked () {
|
|
const { accountId, following } = this.get()
|
|
this.close()
|
|
await setAccountFollowed(accountId, !following, true)
|
|
},
|
|
async onBlockClicked () {
|
|
const { accountId, blocking } = this.get()
|
|
this.close()
|
|
await setAccountBlocked(accountId, !blocking, true)
|
|
},
|
|
async onMuteClicked () {
|
|
const { account, muting } = this.get()
|
|
this.close()
|
|
await toggleMute(account, !muting)
|
|
},
|
|
async onShowReblogsClicked () {
|
|
const { accountId, showingReblogs } = this.get()
|
|
this.close()
|
|
await setShowReblogs(accountId, !showingReblogs, true)
|
|
},
|
|
async onBlockDomainClicked () {
|
|
const { accountId, domain, blockingDomain } = this.get()
|
|
this.close()
|
|
await setDomainBlocked(accountId, domain, !blockingDomain, true)
|
|
},
|
|
async onCopyClicked () {
|
|
const { account } = this.get()
|
|
const { url } = account
|
|
this.close()
|
|
await copyText(url)
|
|
},
|
|
async onReport () {
|
|
const { account } = this.get()
|
|
this.close()
|
|
await reportStatusOrAccount({ account })
|
|
}
|
|
},
|
|
components: {
|
|
ModalDialog,
|
|
GenericDialogList
|
|
}
|
|
}
|
|
</script>
|