diff --git a/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue b/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue index dc1742cb..d7c5801f 100644 --- a/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue +++ b/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue @@ -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 diff --git a/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile/Followers.vue b/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile/Followers.vue index 03a30174..d893965b 100644 --- a/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile/Followers.vue +++ b/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile/Followers.vue @@ -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) + } } } } diff --git a/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile/Follows.vue b/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile/Follows.vue index 26f2d0a4..745ac15a 100644 --- a/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile/Follows.vue +++ b/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile/Follows.vue @@ -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) + } } } } diff --git a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js index e5a1859b..47247e3e 100644 --- a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js +++ b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js @@ -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)