From de8eb815efe0c7dc53389ede96dcaca540109a9d Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Wed, 10 Jun 2020 01:06:35 +0900 Subject: [PATCH] refs #1427 Get and show identity proof of accounts --- .../Contents/SideBar/AccountProfile.spec.ts | 3 +- .../Contents/SideBar/AccountProfile.vue | 49 ++++++++++++++++++- .../Contents/SideBar/AccountProfile.ts | 27 ++++++++-- 3 files changed, 72 insertions(+), 7 deletions(-) diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/SideBar/AccountProfile.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/SideBar/AccountProfile.spec.ts index 826c29c9..69fcea81 100644 --- a/spec/renderer/integration/store/TimelineSpace/Contents/SideBar/AccountProfile.spec.ts +++ b/spec/renderer/integration/store/TimelineSpace/Contents/SideBar/AccountProfile.spec.ts @@ -7,7 +7,8 @@ const state = (account: Entity.Account | null): AccountProfileState => { return { loading: false, relationship: null, - account: account + account: account, + identityProofs: [] } } diff --git a/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue b/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue index 3d572d5d..ea0e3119 100644 --- a/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue +++ b/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue @@ -69,6 +69,14 @@
+
+
+
+ {{ identity.provider }} +
+
{{ identity.provider_username }}
+
+
@@ -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, @@ -147,10 +156,10 @@ export default { ...mapGetters('TimelineSpace/Contents/SideBar/AccountProfile', ['isOwnProfile']) }, watch: { - account: function() { + account: function () { this.activeTab = 1 }, - loading: function(newState, _oldState) { + loading: function (newState, _oldState) { this.$emit('change-loading', newState) } }, @@ -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; diff --git a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.ts b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.ts index 484c3e72..29760e3e 100644 --- a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.ts +++ b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.ts @@ -20,6 +20,7 @@ export type AccountProfileState = { account: Entity.Account | null relationship: Entity.Relationship | null loading: boolean + identityProofs: Array } 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 = { @@ -51,11 +54,14 @@ const mutations: MutationTree = { }, [MUTATION_TYPES.CHANGE_LOADING]: (state, value: boolean) => { state.loading = value + }, + [MUTATION_TYPES.CHANGE_IDENTITY_PROOFS]: (state, values: Array) => { + state.identityProofs = values } } const actions: ActionTree = { - fetchAccount: async ({ rootState }, accountID: string): Promise => { + fetchAccount: async ({ rootState, dispatch }, accountID: string): Promise => { const client = generator( rootState.TimelineSpace.sns, rootState.TimelineSpace.account.baseURL, @@ -64,6 +70,7 @@ const actions: ActionTree = { rootState.App.proxyConfiguration ) const res = await client.getAccount(accountID) + dispatch('identityProofs', res.data) return res.data }, searchAccount: async ({ rootState }, searchAccount: SearchAccount): Promise => { @@ -103,6 +110,7 @@ const actions: ActionTree = { }, 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 => { @@ -184,7 +192,7 @@ const actions: ActionTree = { 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 = { 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) } }