mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
reload completed tasks after resync is finished - always reload completed tasks (#10614)
This commit is contained in:
@@ -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');
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
@@ -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?
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user