refs #816 Fix account profile API call

This commit is contained in:
AkiraFukushima 2020-03-19 23:18:23 +09:00
parent d662735729
commit 68dae08dec
6 changed files with 32 additions and 31 deletions

12
package-lock.json generated
View File

@ -3788,9 +3788,9 @@
} }
}, },
"@types/ws": { "@types/ws": {
"version": "7.2.2", "version": "7.2.3",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.2.2.tgz", "resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.2.3.tgz",
"integrity": "sha512-oqnI3DbGCVI9zJ/WHdFo3CUE8jQ8CVQDUIKaDtlTcNeT4zs6UCg9Gvk5QrFx2QPkRszpM6yc8o0p4aGjCsTi+w==", "integrity": "sha512-VT/GK7nvDA7lfHy40G3LKM+ICqmdIsBLBHGXcWD97MtqQEjNMX+7Gudo8YGpaSlYdTX7IFThhCE8Jx09HegymQ==",
"requires": { "requires": {
"@types/node": "*" "@types/node": "*"
} }
@ -16593,9 +16593,9 @@
"dev": true "dev": true
}, },
"megalodon": { "megalodon": {
"version": "3.0.0-rc.3", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/megalodon/-/megalodon-3.0.0-rc.3.tgz", "resolved": "https://registry.npmjs.org/megalodon/-/megalodon-3.0.0.tgz",
"integrity": "sha512-EMXBBw/U0buIZzOBX0XhPvGJ8WTfo4I3Xxl5UQj3fGqUsdb3LJqCE232oo9zoAiktFP0JYbrEXgUkvG+w70R1w==", "integrity": "sha512-H0BwhizpOu0A0LOVJoy8jBKlFl1NiP+PNH2rZ8hMu5Z8qHt4Z9d3CrPX2cMX9j+c+rUhQzEdnWzu62SFcvzY3A==",
"requires": { "requires": {
"@types/oauth": "^0.9.0", "@types/oauth": "^0.9.0",
"@types/ws": "^7.2.0", "@types/ws": "^7.2.0",

View File

@ -184,7 +184,7 @@
"hoek": "^6.1.3", "hoek": "^6.1.3",
"i18next": "^19.0.3", "i18next": "^19.0.3",
"lodash": "^4.17.15", "lodash": "^4.17.15",
"megalodon": "3.0.0-rc.3", "megalodon": "3.0.0",
"moment": "^2.24.0", "moment": "^2.24.0",
"mousetrap": "^1.6.3", "mousetrap": "^1.6.3",
"nedb": "^1.8.0", "nedb": "^1.8.0",

View File

@ -1,15 +1,16 @@
<template> <template>
<div id="follows"> <div id="follows">
<template v-for="follow in follows"> <template v-for="follow in follows">
<user :user="follow" <user
v-bind:key="follow.id" :user="follow"
:relationship="targetRelation(follow.id)" v-bind:key="follow.id"
@followAccount="followAccount" :relationship="targetRelation(follow.id)"
@unfollowAccount="unfollowAccount" @followAccount="followAccount"
> @unfollowAccount="unfollowAccount"
</user> >
</template> </user>
</div> </template>
</div>
</template> </template>
<script> <script>
@ -18,7 +19,7 @@ import User from '~/src/renderer/components/molecules/User'
export default { export default {
name: 'follows', name: 'follows',
props: [ 'account' ], props: ['account'],
components: { User }, components: { User },
computed: { computed: {
...mapState('TimelineSpace/Contents/SideBar/AccountProfile/Follows', { ...mapState('TimelineSpace/Contents/SideBar/AccountProfile/Follows', {
@ -26,21 +27,22 @@ export default {
relationships: state => state.relationships relationships: state => state.relationships
}) })
}, },
created () { created() {
this.load() this.load()
}, },
watch: { watch: {
account: function (_newAccount, _oldAccount) { account: function(_newAccount, _oldAccount) {
this.load() this.load()
} }
}, },
methods: { methods: {
async load () { async load() {
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', true) this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', true)
try { try {
const follows = await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/Follows/fetchFollows', this.account) const follows = await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/Follows/fetchFollows', this.account)
await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/Follows/fetchRelationships', follows) await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/Follows/fetchRelationships', follows)
} catch (err) { } catch (err) {
console.error(err)
this.$message({ this.$message({
message: this.$t('message.follows_fetch_error'), message: this.$t('message.follows_fetch_error'),
type: 'error' type: 'error'
@ -49,10 +51,10 @@ export default {
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', false) this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', false)
} }
}, },
targetRelation (id) { targetRelation(id) {
return this.relationships.find(r => r.id === id) return this.relationships.find(r => r.id === id)
}, },
async followAccount (account) { async followAccount(account) {
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', true) this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', true)
try { try {
await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/follow', account) await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/follow', account)
@ -66,7 +68,7 @@ export default {
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', false) this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', false)
} }
}, },
async unfollowAccount (account) { async unfollowAccount(account) {
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', true) this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', true)
try { try {
await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/unfollow', account) await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/unfollow', account)
@ -84,5 +86,4 @@ export default {
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped></style>
</style>

View File

@ -114,8 +114,8 @@ const actions: ActionTree<AccountProfileState, RootState> = {
rootState.App.userAgent, rootState.App.userAgent,
rootState.App.proxyConfiguration rootState.App.proxyConfiguration
) )
const res = await client.getRelationship([account.id]) const res = await client.getRelationship(account.id)
commit(MUTATION_TYPES.CHANGE_RELATIONSHIP, res.data[0]) commit(MUTATION_TYPES.CHANGE_RELATIONSHIP, res.data)
return res.data return res.data
}, },
reload: async ({ dispatch, state, commit }) => { reload: async ({ dispatch, state, commit }) => {

View File

@ -49,7 +49,7 @@ const actions: ActionTree<FollowersState, RootState> = {
rootState.App.userAgent, rootState.App.userAgent,
rootState.App.proxyConfiguration rootState.App.proxyConfiguration
) )
const res = await client.getRelationship(ids) const res = await client.getRelationships(ids)
commit(MUTATION_TYPES.UPDATE_RELATIONSHIPS, res.data) commit(MUTATION_TYPES.UPDATE_RELATIONSHIPS, res.data)
return res.data return res.data
} }

View File

@ -48,7 +48,7 @@ const actions: ActionTree<FollowsState, RootState> = {
rootState.App.userAgent, rootState.App.userAgent,
rootState.App.proxyConfiguration rootState.App.proxyConfiguration
) )
const res = await client.getRelationship(ids) const res = await client.getRelationships(ids)
commit(MUTATION_TYPES.UPDATE_RELATIONSHIPS, res.data) commit(MUTATION_TYPES.UPDATE_RELATIONSHIPS, res.data)
return res.data return res.data
} }