2018-04-05 06:45:19 +02:00
|
|
|
<ModalDialog
|
2018-04-09 01:56:20 +02:00
|
|
|
:id
|
2018-04-05 06:45:19 +02:00
|
|
|
:label
|
|
|
|
:title
|
|
|
|
background="var(--main-bg)"
|
|
|
|
>
|
|
|
|
<GenericDialogList :items on:click="onClick(event)"/>
|
|
|
|
</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-04-09 01:56:20 +02:00
|
|
|
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'
|
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-04-15 07:18:48 +02:00
|
|
|
// begin account data copypasta
|
|
|
|
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) => {
|
|
|
|
if (typeof following === 'undefined' || !account) {
|
|
|
|
return ''
|
|
|
|
}
|
|
|
|
return (following || followRequested)
|
|
|
|
? `Unfollow @${acct}`
|
|
|
|
: `Follow @${acct}`
|
|
|
|
},
|
|
|
|
followIcon: (following, followRequested) => {
|
|
|
|
return following ? '#fa-user-times' : followRequested ? '#fa-hourglass' : '#fa-user-plus'
|
|
|
|
},
|
|
|
|
blockLabel: (blocking, acct) => {
|
|
|
|
return blocking ? `Unblock @${acct}` : `Block @${acct}`
|
|
|
|
},
|
|
|
|
blockIcon: (blocking) => blocking ? '#fa-unlock' : '#fa-ban',
|
|
|
|
muteLabel: (muting, acct) => {
|
|
|
|
return muting ? `Unmute @${acct}` : `Mute @${acct}`
|
|
|
|
},
|
|
|
|
muteIcon: (muting) => muting ? '#fa-volume-up' : '#fa-volume-off',
|
|
|
|
// end account data copypasta
|
|
|
|
items: (blockLabel, blocking, blockIcon, muteLabel, muteIcon,
|
|
|
|
followLabel, followIcon, following, followRequested,
|
|
|
|
accountId, verifyCredentialsId, acct) => {
|
|
|
|
let isUser = accountId === verifyCredentialsId
|
|
|
|
return [
|
|
|
|
!isUser && {
|
2018-04-05 06:45:19 +02:00
|
|
|
key: 'mention',
|
2018-04-15 07:18:48 +02:00
|
|
|
label: `Mention @${acct}`,
|
2018-04-05 06:45:19 +02:00
|
|
|
icon: '#fa-comments'
|
2018-04-15 03:47:55 +02:00
|
|
|
},
|
2018-04-15 07:18:48 +02:00
|
|
|
!isUser && !blocking && {
|
|
|
|
key: 'follow',
|
|
|
|
label: followLabel,
|
|
|
|
icon: followIcon
|
|
|
|
},
|
|
|
|
!isUser && {
|
2018-04-15 03:47:55 +02:00
|
|
|
key: 'block',
|
2018-04-15 07:18:48 +02:00
|
|
|
label: blockLabel,
|
|
|
|
icon: blockIcon
|
|
|
|
},
|
|
|
|
!isUser && !blocking && {
|
|
|
|
key: 'mute',
|
|
|
|
label: muteLabel,
|
|
|
|
icon: muteIcon
|
2018-04-05 06:45:19 +02:00
|
|
|
}
|
2018-04-15 07:18:48 +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-15 03:47:55 +02:00
|
|
|
onClick(item) {
|
|
|
|
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-04-15 03:47:55 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
async onMentionClicked() {
|
2018-04-15 07:18:48 +02:00
|
|
|
let acct = this.get('acct')
|
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-07 09:21:00 +02:00
|
|
|
let dialogs = await importDialogs()
|
|
|
|
dialogs.showComposeDialog()
|
2018-04-09 01:56:20 +02:00
|
|
|
this.close()
|
2018-04-15 03:47:55 +02:00
|
|
|
},
|
2018-04-15 07:18:48 +02:00
|
|
|
async onFollowClicked() {
|
|
|
|
let accountId = this.get('accountId')
|
|
|
|
let following = this.get('following')
|
|
|
|
this.close()
|
|
|
|
await setAccountFollowed(accountId, !following, true)
|
|
|
|
},
|
2018-04-15 03:47:55 +02:00
|
|
|
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-15 07:18:48 +02:00
|
|
|
},
|
|
|
|
async onMuteClicked() {
|
|
|
|
let accountId = this.get('accountId')
|
|
|
|
let muting = this.get('muting')
|
|
|
|
this.close()
|
|
|
|
await setAccountMuted(accountId, !muting, true)
|
2018-04-05 06:45:19 +02:00
|
|
|
}
|
2018-04-09 01:56:20 +02:00
|
|
|
},
|
|
|
|
components: {
|
|
|
|
ModalDialog,
|
|
|
|
GenericDialogList
|
|
|
|
},
|
2018-04-05 06:45:19 +02:00
|
|
|
}
|
|
|
|
</script>
|