From 3ea7eb48b4c9cea4772a8f811e3d30d6854e699e Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Sun, 10 Oct 2021 19:41:45 +0200 Subject: [PATCH] fix profile display --- src/store/profile.js | 15 +++++++++------ src/views/profile/View.vue | 10 +++++++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/store/profile.js b/src/store/profile.js index 1cf28c6..9dcd92f 100644 --- a/src/store/profile.js +++ b/src/store/profile.js @@ -54,17 +54,20 @@ export default { } }, actions: { - onError({commit}) { + onError({commit, dispatch}) { commit('setError') - commit('clearProfileId') - commit('clearProfile') - commit('setNotLoading') - commit('hideSpinner') + dispatch('clear') }, onNotFound({commit, dispatch}) { dispatch('onError') commit('setNotFound', true) }, + clear({commit}) { + commit('clearProfileId') + commit('clearProfile') + commit('hideSpinner') + commit('setNotLoading') + }, async load({state, commit, dispatch, rootState}, profileId) { if (state.loading) { return @@ -111,7 +114,7 @@ export default { const responseData = await response.json() commit('setProfile', responseData.profile) commit('hideSpinner') - commit('setNotSearching') + commit('setNotLoading') } } } diff --git a/src/views/profile/View.vue b/src/views/profile/View.vue index 3f76f9b..a7bb479 100644 --- a/src/views/profile/View.vue +++ b/src/views/profile/View.vue @@ -112,7 +112,8 @@ export default { }, methods: { ...mapActions({ - load: 'profile/load' + loadProfile: 'profile/load', + clearStore: 'profile/clear', }) }, computed: { @@ -126,8 +127,11 @@ export default { }, async created() { const id = parseInt(this.$route.params.memberId, 10) - this.load(id) - } + this.loadProfile(id) + }, + unmounted() { + this.clearStore() + }, };