refs #1427 Get and show identity proof of accounts
This commit is contained in:
parent
0f15169c53
commit
de8eb815ef
|
@ -7,7 +7,8 @@ const state = (account: Entity.Account | null): AccountProfileState => {
|
|||
return {
|
||||
loading: false,
|
||||
relationship: null,
|
||||
account: account
|
||||
account: account,
|
||||
identityProofs: []
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,14 @@
|
|||
<div class="note" v-html="note(account)" @click.capture.prevent="noteClick"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="identity">
|
||||
<dl v-for="(identity, index) in identityProofs" :key="index">
|
||||
<dt>
|
||||
{{ identity.provider }}
|
||||
</dt>
|
||||
<dd @click.capture.prevent="identityOpen(identity.profile_url)">{{ identity.provider_username }}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="metadata">
|
||||
<dl v-for="(data, index) in account.fields" :key="index">
|
||||
<dt>
|
||||
|
@ -139,6 +147,7 @@ export default {
|
|||
}),
|
||||
...mapState('TimelineSpace/Contents/SideBar/AccountProfile', {
|
||||
account: state => state.account,
|
||||
identityProofs: state => state.identityProofs,
|
||||
relationship: state => state.relationship,
|
||||
loading: state => state.loading,
|
||||
muting: state => state.relationship && state.relationship.muting,
|
||||
|
@ -231,6 +240,9 @@ export default {
|
|||
if (link !== null) {
|
||||
return window.shell.openExternal(link)
|
||||
}
|
||||
},
|
||||
identityOpen(link) {
|
||||
return window.shell.openExternal(link)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -341,6 +353,39 @@ export default {
|
|||
}
|
||||
}
|
||||
|
||||
.identity {
|
||||
dl {
|
||||
display: flex;
|
||||
border-top: 1px solid var(--theme-border-color);
|
||||
margin: 0;
|
||||
|
||||
dt {
|
||||
background-color: var(--theme-selected-background-color);
|
||||
flex: 0 0 auto;
|
||||
width: 120px;
|
||||
text-align: center;
|
||||
padding: 16px 4px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
dd {
|
||||
background-color: rgba(121, 189, 154, 0.25);
|
||||
flex: 1 1 auto;
|
||||
padding: 16px 4px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
text-align: center;
|
||||
margin: 0;
|
||||
color: #79bd9a;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.metadata {
|
||||
dl {
|
||||
display: flex;
|
||||
|
|
|
@ -20,6 +20,7 @@ export type AccountProfileState = {
|
|||
account: Entity.Account | null
|
||||
relationship: Entity.Relationship | null
|
||||
loading: boolean
|
||||
identityProofs: Array<Entity.IdentityProof>
|
||||
}
|
||||
|
||||
type AccountProfileModule = {
|
||||
|
@ -33,13 +34,15 @@ export type AccountProfileModuleState = AccountProfileModule & AccountProfileSta
|
|||
const state = (): AccountProfileState => ({
|
||||
account: null,
|
||||
relationship: null,
|
||||
loading: false
|
||||
loading: false,
|
||||
identityProofs: []
|
||||
})
|
||||
|
||||
export const MUTATION_TYPES = {
|
||||
CHANGE_ACCOUNT: 'changeAccount',
|
||||
CHANGE_RELATIONSHIP: 'changeRelationship',
|
||||
CHANGE_LOADING: 'changeLoading'
|
||||
CHANGE_LOADING: 'changeLoading',
|
||||
CHANGE_IDENTITY_PROOFS: 'changeIdentityProofs'
|
||||
}
|
||||
|
||||
const mutations: MutationTree<AccountProfileState> = {
|
||||
|
@ -51,11 +54,14 @@ const mutations: MutationTree<AccountProfileState> = {
|
|||
},
|
||||
[MUTATION_TYPES.CHANGE_LOADING]: (state, value: boolean) => {
|
||||
state.loading = value
|
||||
},
|
||||
[MUTATION_TYPES.CHANGE_IDENTITY_PROOFS]: (state, values: Array<Entity.IdentityProof>) => {
|
||||
state.identityProofs = values
|
||||
}
|
||||
}
|
||||
|
||||
const actions: ActionTree<AccountProfileState, RootState> = {
|
||||
fetchAccount: async ({ rootState }, accountID: string): Promise<Entity.Account> => {
|
||||
fetchAccount: async ({ rootState, dispatch }, accountID: string): Promise<Entity.Account> => {
|
||||
const client = generator(
|
||||
rootState.TimelineSpace.sns,
|
||||
rootState.TimelineSpace.account.baseURL,
|
||||
|
@ -64,6 +70,7 @@ const actions: ActionTree<AccountProfileState, RootState> = {
|
|||
rootState.App.proxyConfiguration
|
||||
)
|
||||
const res = await client.getAccount(accountID)
|
||||
dispatch('identityProofs', res.data)
|
||||
return res.data
|
||||
},
|
||||
searchAccount: async ({ rootState }, searchAccount: SearchAccount): Promise<Entity.Account> => {
|
||||
|
@ -103,6 +110,7 @@ const actions: ActionTree<AccountProfileState, RootState> = {
|
|||
},
|
||||
changeAccount: ({ commit, dispatch }, account: Entity.Account) => {
|
||||
dispatch('fetchRelationship', account)
|
||||
dispatch('identityProofs', account)
|
||||
commit(MUTATION_TYPES.CHANGE_ACCOUNT, account)
|
||||
},
|
||||
fetchRelationship: async ({ commit, rootState }, account: Entity.Account): Promise<Entity.Relationship> => {
|
||||
|
@ -184,7 +192,7 @@ const actions: ActionTree<AccountProfileState, RootState> = {
|
|||
dispatch('fetchRelationship', account)
|
||||
return res.data
|
||||
},
|
||||
unblock: async ({ rootState, commit, dispatch }, account: Account) => {
|
||||
unblock: async ({ rootState, commit, dispatch }, account: Entity.Account) => {
|
||||
const client = generator(
|
||||
rootState.TimelineSpace.sns,
|
||||
rootState.TimelineSpace.account.baseURL,
|
||||
|
@ -196,6 +204,17 @@ const actions: ActionTree<AccountProfileState, RootState> = {
|
|||
commit(MUTATION_TYPES.CHANGE_RELATIONSHIP, res.data)
|
||||
dispatch('fetchRelationship', account)
|
||||
return res.data
|
||||
},
|
||||
identityProofs: async ({ rootState, commit }, account: Entity.Account) => {
|
||||
const client = generator(
|
||||
rootState.TimelineSpace.sns,
|
||||
rootState.TimelineSpace.account.baseURL,
|
||||
rootState.TimelineSpace.account.accessToken,
|
||||
rootState.App.userAgent,
|
||||
rootState.App.proxyConfiguration
|
||||
)
|
||||
const res = await client.getIdentityProof(account.id)
|
||||
commit(MUTATION_TYPES.CHANGE_IDENTITY_PROOFS, res.data)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue