pinafore/routes/_components/dialog/StatusOptionsDialog.html

69 lines
2.3 KiB
HTML
Raw Normal View History

2018-03-12 02:40:32 +00:00
<ModalDialog :label :shown :closed :title background="var(--main-bg)">
<GenericDialogList :items on:click="onClick(event)"/>
</ModalDialog>
<script>
import ModalDialog from './ModalDialog.html'
import { store } from '../../_store/store'
import GenericDialogList from './GenericDialogList.html'
import { setAccountFollowed } from '../../_actions/follow'
2018-03-14 15:36:12 +00:00
import { doDeleteStatus } from '../../_actions/delete'
2018-03-12 02:40:32 +00:00
export default {
computed: {
relationship: ($currentAccountRelationship) => $currentAccountRelationship,
account: ($currentAccountProfile) => $currentAccountProfile,
2018-03-14 15:36:12 +00:00
verifyCredentials: ($currentVerifyCredentials) => $currentVerifyCredentials,
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
accountName: (account) => account && (account.display_name || account.acct),
accountId: (account) => account && account.id,
2018-03-15 05:14:06 +00:00
followLabel: (following, followRequested, accountName) => {
2018-03-12 02:40:32 +00:00
if (typeof following === 'undefined' || !accountName) {
return ''
}
2018-03-15 05:14:06 +00:00
return (following || followRequested)
? `Unfollow ${accountName}`
: `Follow ${accountName}`
2018-03-12 02:40:32 +00:00
},
2018-03-15 05:14:06 +00:00
items: (followLabel, following, followRequested, accountId, verifyCredentialsId) => (
2018-03-14 15:36:12 +00:00
[
accountId !== verifyCredentialsId &&
2018-03-12 02:40:32 +00:00
{
key: 'follow',
label: followLabel,
2018-03-15 05:14:06 +00:00
icon: following ? '#fa-user-times' : followRequested ? '#fa-hourglass' : '#fa-user-plus'
2018-03-14 15:36:12 +00:00
},
accountId === verifyCredentialsId &&
{
key: 'delete',
label: 'Delete',
icon: '#fa-trash'
2018-03-12 02:40:32 +00:00
}
2018-03-14 15:36:12 +00:00
].filter(Boolean)
)
2018-03-12 02:40:32 +00:00
},
components: {
ModalDialog,
GenericDialogList
},
store: () => store,
methods: {
async show() {
this.set({shown: true})
},
async onClick(item) {
if (item.key === 'follow') {
let accountId = this.get('accountId')
let following = this.get('following')
await setAccountFollowed(accountId, !following, true)
this.set({closed: true})
2018-03-14 15:36:12 +00:00
} else if (item.key === 'delete') {
let statusId = this.get('statusId')
await doDeleteStatus(statusId)
this.set({closed: true})
2018-03-12 02:40:32 +00:00
}
}
}
}
</script>