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

View File

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

View File

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

View File

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

View File

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

View File

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