Fix not reloading tasks of a saved filter after editing it

This commit is contained in:
kolaente 2021-07-20 22:16:44 +02:00
parent d81b4117f5
commit 2779cfc140
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -31,6 +31,7 @@ export default {
}, },
watch: { watch: {
'$route.query': 'loadTasksForPage', // Only listen for query path changes '$route.query': 'loadTasksForPage', // Only listen for query path changes
'$route.path': 'loadTasksOnSavedFilter',
}, },
beforeMount() { beforeMount() {
// Triggering loading the tasks in beforeMount lets the component maintain the current page, therefore the page // Triggering loading the tasks in beforeMount lets the component maintain the current page, therefore the page
@ -45,13 +46,15 @@ export default {
page, page,
search = '', search = '',
params = null, params = null,
forceLoading = false,
) { ) {
// Because this function is triggered every time on topNavigation, we're putting a condition here to only load it when we actually want to show tasks // Because this function is triggered every time on topNavigation, we're putting a condition here to only load it when we actually want to show tasks
// FIXME: This is a bit hacky -> Cleanup. // FIXME: This is a bit hacky -> Cleanup.
if ( if (
this.$route.name !== 'list.list' && this.$route.name !== 'list.list' &&
this.$route.name !== 'list.table' this.$route.name !== 'list.table' &&
!forceLoading
) { ) {
return return
} }
@ -72,7 +75,7 @@ export default {
search: search, search: search,
page: page, page: page,
} }
if (JSON.stringify(currentList) === JSON.stringify(this.loadedList)) { if (JSON.stringify(currentList) === JSON.stringify(this.loadedList) && !forceLoading) {
return return
} }
@ -130,6 +133,11 @@ export default {
} }
this.initTasks(page, search) this.initTasks(page, search)
}, },
loadTasksOnSavedFilter() {
if(typeof this.$route.params.listId !== 'undefined' && parseInt(this.$route.params.listId) < 0) {
this.loadTasks(1, '', null, true)
}
},
sortTasks() { sortTasks() {
if (this.tasks === null || this.tasks === []) { if (this.tasks === null || this.tasks === []) {
return return