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

76 lines
1.9 KiB
HTML
Raw Normal View History

2018-04-05 04:45:19 +00:00
<ModalDialog
:id
2018-04-05 04:45:19 +00:00
:label
:title
background="var(--main-bg)"
>
<GenericDialogList :items on:click="onClick(event)"/>
</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'
import { importDialogs } from '../../../_utils/asyncModules'
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-05 04:45:19 +00:00
export default {
oncreate,
store: () => store,
data: () => ({
id: createDialogId()
}),
2018-04-05 04:45:19 +00:00
computed: {
blocking: (relationship) => relationship && relationship.blocking,
items: (account, blocking) => (
2018-04-05 04:45:19 +00:00
[
{
key: 'mention',
label: `Mention @${account.acct}`,
2018-04-05 04:45:19 +00:00
icon: '#fa-comments'
},
{
key: 'block',
label: blocking ? `Unblock @${account.acct}` : `Block @${account.acct}`,
icon: blocking ? '#fa-unlock' : '#fa-ban'
2018-04-05 04:45:19 +00:00
}
]
)
},
methods: {
show,
close,
onClick(item) {
switch (item.key) {
case 'mention':
return this.onMentionClicked()
case 'block':
return this.onBlockClicked()
}
},
async onMentionClicked() {
2018-04-05 04:45:19 +00:00
let account = this.get('account')
2018-04-07 07:21:00 +00:00
this.store.setComposeData('dialog', {
2018-04-05 04:45:19 +00:00
text: `@${account.acct} `
})
2018-04-07 07:21:00 +00:00
let dialogs = await importDialogs()
dialogs.showComposeDialog()
this.close()
},
async onBlockClicked() {
let account = this.get('account')
let blocking = this.get('blocking')
let accountId = account.id
this.close()
await setAccountBlocked(accountId, !blocking, true)
2018-04-05 04:45:19 +00:00
}
},
components: {
ModalDialog,
GenericDialogList
},
2018-04-05 04:45:19 +00:00
}
</script>