/
AccountProfileOptionsDialog.html
187 lines (186 loc) · 5.86 KB
/
AccountProfileOptionsDialog.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<ModalDialog
{id}
{label}
{title}
background="var(--main-bg)"
>
<GenericDialogList selectable={false} {items} on:click="onClick(event)"/>
</ModalDialog>
<script>
import ModalDialog from './ModalDialog.html'
import { store } from '../../../_store/store'
import GenericDialogList from './GenericDialogList.html'
import { importShowComposeDialog, importShowCopyDialog } 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'
import { setAccountMuted } from '../../../_actions/mute'
import { setAccountFollowed } from '../../../_actions/follow'
import { setShowReblogs } from '../../../_actions/setShowReblogs'
import { setDomainBlocked } from '../../../_actions/setDomainBlocked'
export default {
oncreate,
store: () => store,
data: () => ({
id: createDialogId()
}),
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 }) => {
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,
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))
},
methods: {
show,
close,
onClick (item) {
switch (item.key) {
case 'mention':
return this.onMentionClicked()
case 'follow':
return this.onFollowClicked()
case 'block':
return this.onBlockClicked()
case 'mute':
return this.onMuteClicked()
case 'showReblogs':
return this.onShowReblogsClicked()
case 'blockDomain':
return this.onBlockDomainClicked()
case 'copy':
return this.onCopyClicked()
}
},
async onMentionClicked () {
let { acct } = this.get()
this.store.setComposeData('dialog', {
text: `@${acct} `
})
let showComposeDialog = await importShowComposeDialog()
showComposeDialog()
this.close()
},
async onFollowClicked () {
let { accountId, following } = this.get()
this.close()
await setAccountFollowed(accountId, !following, true)
},
async onBlockClicked () {
let { accountId, blocking } = this.get()
this.close()
await setAccountBlocked(accountId, !blocking, true)
},
async onMuteClicked () {
let { accountId, muting } = this.get()
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
let showCopyDialog = await importShowCopyDialog()
showCopyDialog(url)
}
},
components: {
ModalDialog,
GenericDialogList
}
}
</script>