From 6fb9030b96859c6c447fd66b7078d41aeb3f5dcf Mon Sep 17 00:00:00 2001 From: negue Date: Fri, 24 Aug 2018 22:04:59 +0200 Subject: [PATCH] reload completed tasks after resync is finished - always reload completed tasks (#10614) --- website/client/components/header/menu.vue | 5 +++-- website/client/components/tasks/column.vue | 4 ++-- website/client/store/actions/tasks.js | 15 ++------------- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/website/client/components/header/menu.vue b/website/client/components/header/menu.vue index 7e72975a0e..ed0fe4986e 100644 --- a/website/client/components/header/menu.vue +++ b/website/client/components/header/menu.vue @@ -396,12 +396,13 @@ export default { toggleUserDropdown () { this.isUserDropdownOpen = !this.isUserDropdownOpen; }, - sync () { + async sync () { this.$root.$emit('habitica::resync-requested'); - return Promise.all([ + await Promise.all([ this.$store.dispatch('user:fetch', {forceLoad: true}), this.$store.dispatch('tasks:fetchUserTasks', {forceLoad: true}), ]); + this.$root.$emit('habitica::resync-completed'); }, async getUserGroupPlans () { this.$store.state.groupPlans = await this.$store.dispatch('guilds:getGroupPlans'); diff --git a/website/client/components/tasks/column.vue b/website/client/components/tasks/column.vue index 6d26341a0a..58c2ff139f 100644 --- a/website/client/components/tasks/column.vue +++ b/website/client/components/tasks/column.vue @@ -449,9 +449,9 @@ export default { }); if (this.type !== 'todo') return; - this.$root.$on('habitica::resync-requested', () => { + this.$root.$on('habitica::resync-completed', () => { if (this.activeFilter.label !== 'complete2') return; - this.loadCompletedTodos(true); + this.loadCompletedTodos(); }); }, destroyed () { diff --git a/website/client/store/actions/tasks.js b/website/client/store/actions/tasks.js index d6d702d8af..4e9a0e16d2 100644 --- a/website/client/store/actions/tasks.js +++ b/website/client/store/actions/tasks.js @@ -19,13 +19,13 @@ export function fetchUserTasks (store, options = {}) { }); } -export async function fetchCompletedTodos (store, forceLoad = false) { +export async function fetchCompletedTodos (store) { // Wait for the user to be loaded before deserializing // because user.tasksOrder is necessary await store.dispatch('tasks:fetchUserTasks'); const loadStatus = store.state.completedTodosStatus; - if (loadStatus === 'NOT_LOADED' || forceLoad) { + if (loadStatus !== 'LOADING') { store.state.completedTodosStatus = 'LOADING'; const response = await axios.get('/api/v4/tasks/user?type=completedTodos'); @@ -36,17 +36,6 @@ export async function fetchCompletedTodos (store, forceLoad = false) { tasks.todos.push(...completedTodos); store.state.completedTodosStatus = 'LOADED'; - } else if (status === 'LOADED') { - return; - } else if (loadStatus === 'LOADING') { - const watcher = store.watch(state => state.completedTodosStatus, (newLoadingStatus) => { - watcher(); // remove the watcher - if (newLoadingStatus === 'LOADED') { - return; - } else { - throw new Error(); // TODO add reason? - } - }); } }