From 7510215806c4805702188ead32dafce556c26a82 Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Fri, 10 Jul 2020 09:43:53 +0200 Subject: [PATCH] Move code to mutation methods --- src/_store/account.module.js | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/_store/account.module.js b/src/_store/account.module.js index 632558e..677f97f 100644 --- a/src/_store/account.module.js +++ b/src/_store/account.module.js @@ -112,20 +112,11 @@ const actions = { error => commit('logoutFailure', error) ); }, - restore({ dispatch, commit }, { shortKey, longKey, password, systemConfigs, messages, errors }) { - commit('restoreRequest'); - systemConfigs.restoringInProgress = true; + restore({ commit }, { shortKey, longKey, password, systemConfigs, messages, errors }) { + commit('restoreRequest', systemConfigs); userService.restore(shortKey, longKey, password, messages, errors) - .then( - ok => { - commit('restoreSuccess'); - systemConfigs.awaitingRestore = false; - }, - error => { - commit('restoreFailure', error); - systemConfigs.restoringInProgress = false; - } - ); + .then(ok => commit('restoreSuccess', systemConfigs), + error => commit('restoreFailure', systemConfigs, error)); }, forgotPassword({ commit }, {username, messages, errors}) { commit('forgotPasswordRequest'); @@ -309,14 +300,17 @@ const mutations = { console.log('logout failed: '+JSON.stringify(error)); }, - restoreRequest(state) { + restoreRequest(state, systemConfigs) { state.status = Object.assign({}, state.status, {restoring: true}); + systemConfigs.restoringInProgress = true; }, - restoreSuccess(state) { + restoreSuccess(state, systemConfigs) { state.status = Object.assign({}, state.status, {restoring: false}); + systemConfigs.awaitingRestore = false; }, - restoreFailure(state, error) { + restoreFailure(state, systemConfigs, error) { state.status = Object.assign({}, state.status, {restoring: false}); + systemConfigs.restoringInProgress = false; console.log('restore failed: ' + JSON.stringify(error)); },