From 45a22470fa6cc0802cfcf3eaccdd12e5df8710cd Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Sun, 5 Jul 2020 00:01:02 +0200 Subject: [PATCH] fix 9351: sync player that casts spells immediately (#12367) --- website/client/src/app.vue | 8 ++++++-- website/client/src/mixins/spells.js | 11 +++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/website/client/src/app.vue b/website/client/src/app.vue index 24fb4b3580..08c79f349a 100644 --- a/website/client/src/app.vue +++ b/website/client/src/app.vue @@ -369,7 +369,6 @@ export default { const isApiCall = url.indexOf('api/v4') !== -1; const userV = response.data && response.data.userV; - const isCron = url.indexOf('/api/v4/cron') === 0 && method === 'post'; if (this.isUserLoaded && isApiCall && userV) { const oldUserV = this.user._v; @@ -381,9 +380,14 @@ export default { // exclude chat seen requests because with real time chat they would be too many const isChatSeen = url.indexOf('/chat/seen') !== -1 && method === 'post'; // exclude POST /api/v4/cron because the user is synced automatically after cron runs + const isCron = url.indexOf('/api/v4/cron') === 0 && method === 'post'; + // exclude skills casting as they already return the synced user + const isCast = url.indexOf('/api/v4/user/class/cast') !== -1 && method === 'post'; // Something has changed on the user object that was not tracked here, sync the user - if (userV - oldUserV > 1 && !isCron && !isChatSeen && !isUserSync && !isTasksSync) { + if ( + userV - oldUserV > 1 && !isCron && !isChatSeen && !isUserSync && !isTasksSync && !isCast + ) { Promise.all([ this.$store.dispatch('user:fetch', { forceLoad: true }), this.$store.dispatch('tasks:fetchUserTasks', { forceLoad: true }), diff --git a/website/client/src/mixins/spells.js b/website/client/src/mixins/spells.js index 042bc4d38b..a259788042 100644 --- a/website/client/src/mixins/spells.js +++ b/website/client/src/mixins/spells.js @@ -137,6 +137,11 @@ export default { targetId, pinType: spell.pinType, }); + + if (apiResult.data.data.user) { + Object.assign(this.$store.state.user.data, apiResult.data.data.user); + } + let msg = ''; switch (type) { @@ -166,12 +171,6 @@ export default { break; } - if (spell.pinType === 'card') { - const newUserGp = apiResult.data.data.user.stats.gp; - this.$store.state.user.data.stats.gp = newUserGp; - } - - this.markdown(msg); // @TODO: mardown directive? const questProgress = this.questProgress() - beforeQuestProgress;