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

129 lines
4 KiB
HTML
Raw Normal View History

2018-04-05 03:33:17 +00:00
<ModalDialog
:id
2018-04-05 03:33:17 +00:00
:label
:title
background="var(--main-bg)"
>
2018-03-12 02:40:32 +00:00
<GenericDialogList :items on:click="onClick(event)"/>
</ModalDialog>
<script>
import ModalDialog from './ModalDialog.html'
import { store } from '../../../_store/store'
2018-03-12 02:40:32 +00:00
import GenericDialogList from './GenericDialogList.html'
import { setAccountFollowed } from '../../../_actions/follow'
import { doDeleteStatus } from '../../../_actions/delete'
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'
2018-03-12 02:40:32 +00:00
export default {
oncreate,
2018-03-12 02:40:32 +00:00
computed: {
relationship: ($currentAccountRelationship) => $currentAccountRelationship,
account: ($currentAccountProfile) => $currentAccountProfile,
2018-03-14 15:36:12 +00:00
verifyCredentials: ($currentVerifyCredentials) => $currentVerifyCredentials,
2018-04-15 05:18:48 +00:00
// begin account data copypasta
2018-03-14 15:36:12 +00:00
verifyCredentialsId: (verifyCredentials) => verifyCredentials.id,
2018-03-15 05:14:06 +00:00
following: (relationship) => relationship && relationship.following,
followRequested: (relationship) => relationship && relationship.requested,
2018-03-12 02:40:32 +00:00
accountId: (account) => account && account.id,
2018-04-15 05:18:48 +00:00
acct: (account) => account.acct,
muting: (relationship) => relationship.muting,
blocking: (relationship) => relationship.blocking,
2018-04-15 05:18:48 +00:00
followLabel: (following, followRequested, account, acct) => {
2018-04-05 14:44:10 +00:00
if (typeof following === 'undefined' || !account) {
2018-03-12 02:40:32 +00:00
return ''
}
2018-03-15 05:14:06 +00:00
return (following || followRequested)
2018-04-15 05:18:48 +00:00
? `Unfollow @${acct}`
: `Follow @${acct}`
2018-03-12 02:40:32 +00:00
},
2018-04-15 05:18:48 +00:00
followIcon: (following, followRequested) => {
return following ? '#fa-user-times' : followRequested ? '#fa-hourglass' : '#fa-user-plus'
},
2018-04-15 05:18:48 +00:00
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) => {
let isUser = accountId === verifyCredentialsId
return [
isUser && {
key: 'delete',
label: 'Delete',
icon: '#fa-trash'
},
2018-04-15 05:18:48 +00:00
!isUser && !blocking && {
2018-03-12 02:40:32 +00:00
key: 'follow',
label: followLabel,
2018-04-15 05:18:48 +00:00
icon: followIcon
2018-03-14 15:36:12 +00:00
},
2018-04-15 05:18:48 +00:00
!isUser && {
key: 'block',
label: blockLabel,
2018-04-15 05:18:48 +00:00
icon: blockIcon
},
!isUser && !blocking && {
key: 'mute',
label: muteLabel,
icon: muteIcon
2018-03-12 02:40:32 +00:00
}
2018-04-15 05:18:48 +00:00
2018-03-14 15:36:12 +00:00
].filter(Boolean)
2018-04-15 05:18:48 +00:00
}
2018-03-12 02:40:32 +00:00
},
components: {
ModalDialog,
GenericDialogList
},
store: () => store,
methods: {
show,
close,
onClick(item) {
switch (item.key) {
case 'delete':
return this.onDeleteClicked()
case 'follow':
return this.onFollowClicked()
case 'block':
return this.onBlockClicked()
2018-04-15 05:18:48 +00:00
case 'mute':
return this.onMuteClicked()
2018-03-12 02:40:32 +00:00
}
},
async onDeleteClicked() {
let statusId = this.get('statusId')
this.close()
await doDeleteStatus(statusId)
},
async onFollowClicked() {
let accountId = this.get('accountId')
let following = this.get('following')
this.close()
await setAccountFollowed(accountId, !following, true)
},
async onBlockClicked() {
let accountId = this.get('accountId')
let blocking = this.get('blocking')
this.close()
await setAccountBlocked(accountId, !blocking, true)
2018-04-15 05:18:48 +00:00
},
async onMuteClicked() {
let accountId = this.get('accountId')
let muting = this.get('muting')
this.close()
await setAccountMuted(accountId, !muting, true)
2018-03-12 02:40:32 +00:00
}
}
}
</script>