From 372d37e3b35fe2a15d27f35f3f9dce853da347ad Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Thu, 28 May 2020 22:46:08 +0300 Subject: [PATCH] Update reactivity in action that fetches user statuses --- src/store/modules/status.js | 4 ++-- src/store/modules/userProfile.js | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/store/modules/status.js b/src/store/modules/status.js index 724a0dd0..5b908c3c 100644 --- a/src/store/modules/status.js +++ b/src/store/modules/status.js @@ -65,7 +65,7 @@ const status = { } else if (fetchStatusesByInstance) { // called from Statuses by Instance dispatch('FetchStatusesByInstance') } else { // called from Status show page - dispatch('FetchStatus', statusId) + dispatch('FetchStatusAfterUserModeration', statusId) } }, ClearState({ commit }) { @@ -98,7 +98,7 @@ const status = { FetchStatusAfterUserModeration({ commit, dispatch, getters, state }, id) { commit('SET_LOADING', true) fetchStatus(id, getters.authHost, getters.token) - .then((status) => dispatch('SetStatus', status.data)) + .then(status => dispatch('SetStatus', status.data)) commit('SET_LOADING', false) }, async FetchStatusesCount({ commit, getters }, instance) { diff --git a/src/store/modules/userProfile.js b/src/store/modules/userProfile.js index af54072c..0cdc0df6 100644 --- a/src/store/modules/userProfile.js +++ b/src/store/modules/userProfile.js @@ -35,18 +35,21 @@ const userProfile = { dispatch('FetchUserStatuses', { userId, godmode }) }, - async FetchUserStatuses({ commit, getters }, { userId, godmode }) { + FetchUserStatuses({ commit, dispatch, getters }, { userId, godmode }) { commit('SET_STATUSES_LOADING', true) - const statuses = await fetchUserStatuses(userId, getters.authHost, godmode, getters.token) + fetchUserStatuses(userId, getters.authHost, godmode, getters.token) + .then(statuses => dispatch('SetStatuses', statuses.data)) - commit('SET_STATUSES', statuses.data) commit('SET_STATUSES_LOADING', false) }, async FetchUserCredentials({ commit, getters }, { nickname }) { const userResponse = await fetchUserCredentials(nickname, getters.authHost, getters.token) commit('SET_USER_CREDENTIALS', userResponse.data) }, + SetStatuses({ commit }, statuses) { + commit('SET_STATUSES', statuses) + }, async UpdateUserCredentials({ dispatch, getters }, { nickname, credentials }) { await updateUserCredentials(nickname, credentials, getters.authHost, getters.token) dispatch('FetchUserCredentials', { nickname })