refs #657 Fix loading when fetch follows/followers in follow/followers tab
This commit is contained in:
parent
4bf25eb6de
commit
943ee7bee1
|
@ -165,22 +165,30 @@ export default {
|
|||
}
|
||||
},
|
||||
follow (account) {
|
||||
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/follow', account)
|
||||
.catch(() => {
|
||||
this.$message({
|
||||
message: this.$t('message.follow_error'),
|
||||
type: 'error'
|
||||
})
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', true)
|
||||
try {
|
||||
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/follow', account)
|
||||
} catch (err) {
|
||||
this.$message({
|
||||
message: this.$t('message.follow_error'),
|
||||
type: 'error'
|
||||
})
|
||||
} finally {
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', false)
|
||||
}
|
||||
},
|
||||
unfollow (account) {
|
||||
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/unfollow', account)
|
||||
.catch(() => {
|
||||
this.$message({
|
||||
message: this.$t('message.unfollow_error'),
|
||||
type: 'error'
|
||||
})
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', true)
|
||||
try {
|
||||
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/unfollow', account)
|
||||
} catch (err) {
|
||||
this.$message({
|
||||
message: this.$t('message.unfollow_error'),
|
||||
type: 'error'
|
||||
})
|
||||
} finally {
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', false)
|
||||
}
|
||||
},
|
||||
changeTab (index) {
|
||||
this.activeTab = index
|
||||
|
|
|
@ -52,24 +52,32 @@ export default {
|
|||
return this.relationships.find(r => r.id === id)
|
||||
},
|
||||
async followAccount (account) {
|
||||
await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/follow', account)
|
||||
.catch(() => {
|
||||
this.$message({
|
||||
message: this.$t('message.follow_error'),
|
||||
type: 'error'
|
||||
})
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', true)
|
||||
try {
|
||||
await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/follow', account)
|
||||
await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/Followers/fetchRelationships', this.followers)
|
||||
} catch (err) {
|
||||
this.$message({
|
||||
message: this.$t('message.follow_error'),
|
||||
type: 'error'
|
||||
})
|
||||
await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/Followers/fetchRelationships', this.followers)
|
||||
} finally {
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', false)
|
||||
}
|
||||
},
|
||||
async unfollowAccount (account) {
|
||||
await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/unfollow', account)
|
||||
.catch(() => {
|
||||
this.$message({
|
||||
message: this.$t('message.unfollow_error'),
|
||||
type: 'error'
|
||||
})
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', true)
|
||||
try {
|
||||
await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/unfollow', account)
|
||||
await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/Followers/fetchRelationships', this.followers)
|
||||
} catch (err) {
|
||||
this.$message({
|
||||
message: this.$t('message.unfollow_error'),
|
||||
type: 'error'
|
||||
})
|
||||
await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/Followers/fetchRelationships', this.followers)
|
||||
} finally {
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,24 +52,32 @@ export default {
|
|||
return this.relationships.find(r => r.id === id)
|
||||
},
|
||||
async followAccount (account) {
|
||||
await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/follow', account)
|
||||
.catch(() => {
|
||||
this.$message({
|
||||
message: this.$t('message.follow_error'),
|
||||
type: 'error'
|
||||
})
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', true)
|
||||
try {
|
||||
await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/follow', account)
|
||||
await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/Follows/fetchRelationships', this.follows)
|
||||
} catch (err) {
|
||||
this.$message({
|
||||
message: this.$t('message.follow_error'),
|
||||
type: 'error'
|
||||
})
|
||||
await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/Follows/fetchRelationships', this.follows)
|
||||
} finally {
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', false)
|
||||
}
|
||||
},
|
||||
async unfollowAccount (account) {
|
||||
await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/unfollow', account)
|
||||
.catch(() => {
|
||||
this.$message({
|
||||
message: this.$t('message.unfollow_error'),
|
||||
type: 'error'
|
||||
})
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', true)
|
||||
try {
|
||||
await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/unfollow', account)
|
||||
await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/Follows/fetchRelationships', this.follows)
|
||||
} catch (err) {
|
||||
this.$message({
|
||||
message: this.$t('message.unfollow_error'),
|
||||
type: 'error'
|
||||
})
|
||||
await this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/Follows/fetchRelationships', this.follows)
|
||||
} finally {
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,24 +63,17 @@ const AccountProfile = {
|
|||
})
|
||||
},
|
||||
follow ({ state, commit, rootState }, account) {
|
||||
commit('changeLoading', true)
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
return client.post(`/accounts/${account.id}/follow`)
|
||||
.then(res => {
|
||||
commit('changeLoading', false)
|
||||
commit('changeRelationship', res.data)
|
||||
return res.data
|
||||
})
|
||||
.catch(err => {
|
||||
commit('changeLoading', false)
|
||||
throw err
|
||||
})
|
||||
},
|
||||
unfollow ({ commit, rootState }, account) {
|
||||
commit('changeLoading', true)
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
|
@ -90,9 +83,6 @@ const AccountProfile = {
|
|||
commit('changeRelationship', res.data)
|
||||
return res.data
|
||||
})
|
||||
.finally(() => {
|
||||
commit('changeLoading', false)
|
||||
})
|
||||
},
|
||||
close ({ commit }) {
|
||||
commit('changeAccount', null)
|
||||
|
|
Loading…
Reference in New Issue