pinafore/routes/_components/dialog/components/AccountProfileOptionsDialog.html

188 lines
5.9 KiB
HTML
Raw Normal View History

2018-04-05 04:45:19 +00:00
<ModalDialog
{id}
{label}
{title}
2018-04-05 04:45:19 +00:00
background="var(--main-bg)"
>
<GenericDialogList selectable={false} {items} on:click="onClick(event)"/>
2018-04-05 04:45:19 +00:00
</ModalDialog>
<script>
import ModalDialog from './ModalDialog.html'
import { store } from '../../../_store/store'
2018-04-05 04:45:19 +00:00
import GenericDialogList from './GenericDialogList.html'
2018-08-26 23:40:48 +00:00
import { importShowComposeDialog } from '../asyncDialogs'
import { createDialogId } from '../helpers/createDialogId'
import { show } from '../helpers/showDialog'
import { close } from '../helpers/closeDialog'
import { oncreate } from '../helpers/onCreateDialog'
import { setAccountBlocked } from '../../../_actions/block'
2018-04-15 05:18:48 +00:00
import { setAccountMuted } from '../../../_actions/mute'
import { setAccountFollowed } from '../../../_actions/follow'
import { setShowReblogs } from '../../../_actions/setShowReblogs'
import { setDomainBlocked } from '../../../_actions/setDomainBlocked'
2018-08-26 23:40:48 +00:00
import { copyText } from '../../../_actions/copyText'
2018-04-05 04:45:19 +00:00
export default {
oncreate,
store: () => store,
data: () => ({
id: createDialogId()
}),
2018-04-05 04:45:19 +00:00
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,
muting: ({ relationship }) => relationship.muting,
blocking: ({ relationship }) => relationship.blocking,
followLabel: ({ following, followRequested, account, acct }) => {
2018-04-15 05:18:48 +00:00
if (typeof following === 'undefined' || !account) {
return ''
}
return (following || followRequested)
? `Unfollow @${acct}`
: `Follow @${acct}`
},
followIcon: ({ following, followRequested }) => (
following ? '#fa-user-times' : followRequested ? '#fa-hourglass' : '#fa-user-plus'
),
blockLabel: ({ blocking, acct }) => (
blocking ? `Unblock @${acct}` : `Block @${acct}`
),
blockIcon: ({ blocking }) => blocking ? '#fa-unlock' : '#fa-ban',
muteLabel: ({ muting, acct }) => (
muting ? `Unmute @${acct}` : `Mute @${acct}`
),
muteIcon: ({ muting }) => muting ? '#fa-volume-up' : '#fa-volume-off',
isUser: ({ accountId, verifyCredentialsId }) => accountId === verifyCredentialsId,
//
// end copypasta (StatusOptionsDialog.html / AccountProfileOptionsDialog.html)
//
showingReblogs: ({ relationship }) => !!relationship.showing_reblogs,
showReblogsLabel: ({ showingReblogs, acct }) => (
showingReblogs
? `Hide boosts from @${acct}`
: `Show boosts from @${acct}`
),
domain: ({ acct }) => acct.split('@')[1],
blockingDomain: ({ relationship }) => !!relationship.domain_blocking,
blockDomainLabel: ({ blockingDomain, domain }) => (
blockingDomain
? `Unhide ${domain}`
: `Hide ${domain}`
),
items: ({
blockLabel, blocking, blockIcon, muteLabel, muteIcon,
2018-04-20 04:38:01 +00:00
followLabel, followIcon, following, followRequested,
accountId, verifyCredentialsId, acct, isUser, showReblogsLabel,
domain, blockDomainLabel
}) => ([
!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
},
!isUser && following && {
key: 'showReblogs',
label: showReblogsLabel,
icon: '#fa-retweet'
},
!isUser && domain && {
key: 'blockDomain',
label: blockDomainLabel,
icon: '#fa-ban'
},
{
key: 'copy',
label: 'Copy link to account',
icon: '#fa-link'
}
].filter(Boolean))
2018-04-05 04:45:19 +00:00
},
methods: {
show,
close,
2018-04-20 04:38:01 +00:00
onClick (item) {
switch (item.key) {
case 'mention':
return this.onMentionClicked()
2018-04-15 05:18:48 +00:00
case 'follow':
return this.onFollowClicked()
case 'block':
return this.onBlockClicked()
2018-04-15 05:18:48 +00:00
case 'mute':
return this.onMuteClicked()
case 'showReblogs':
return this.onShowReblogsClicked()
case 'blockDomain':
return this.onBlockDomainClicked()
case 'copy':
return this.onCopyClicked()
}
},
2018-04-20 04:38:01 +00:00
async onMentionClicked () {
let { acct } = this.get()
2018-04-07 07:21:00 +00:00
this.store.setComposeData('dialog', {
2018-04-15 05:18:48 +00:00
text: `@${acct} `
2018-04-05 04:45:19 +00:00
})
let showComposeDialog = await importShowComposeDialog()
showComposeDialog()
this.close()
},
2018-04-20 04:38:01 +00:00
async onFollowClicked () {
let { accountId, following } = this.get()
2018-04-15 05:18:48 +00:00
this.close()
await setAccountFollowed(accountId, !following, true)
},
2018-04-20 04:38:01 +00:00
async onBlockClicked () {
let { accountId, blocking } = this.get()
this.close()
await setAccountBlocked(accountId, !blocking, true)
2018-04-15 05:18:48 +00:00
},
2018-04-20 04:38:01 +00:00
async onMuteClicked () {
let { accountId, muting } = this.get()
2018-04-15 05:18:48 +00:00
this.close()
await setAccountMuted(accountId, !muting, true)
},
async onShowReblogsClicked () {
let { accountId, showingReblogs } = this.get()
this.close()
await setShowReblogs(accountId, !showingReblogs, true)
},
async onBlockDomainClicked () {
let { accountId, domain, blockingDomain } = this.get()
this.close()
await setDomainBlocked(accountId, domain, !blockingDomain, true)
},
async onCopyClicked () {
let { account } = this.get()
let { url } = account
2018-08-26 23:40:48 +00:00
this.close()
await copyText(url)
2018-04-05 04:45:19 +00:00
}
},
components: {
ModalDialog,
GenericDialogList
2018-04-20 04:38:01 +00:00
}
2018-04-05 04:45:19 +00:00
}
</script>