From d041384999005d99da62a2e1d5a4a7111a647a81 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 17 Dec 2019 23:03:55 +0100 Subject: [PATCH] Fix loading tasks for the first page after navigating to a new list --- src/components/tasks/ShowListTasks.vue | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/components/tasks/ShowListTasks.vue b/src/components/tasks/ShowListTasks.vue index f25768894..2dd50965c 100644 --- a/src/components/tasks/ShowListTasks.vue +++ b/src/components/tasks/ShowListTasks.vue @@ -132,11 +132,15 @@ this.listService = new ListService() this.taskService = new TaskService() this.taskCollectionService = new TaskCollectionService() - this.taskEditTask = null - this.isTaskEdit = false - this.loadTasks(1) + this.initTasks(1) }, methods: { + // This function initializes the tasks page and loads the first page of tasks + initTasks(page) { + this.taskEditTask = null + this.isTaskEdit = false + this.loadTasks(page) + }, addTask() { let task = new TaskModel({text: this.newTaskText, listID: this.$route.params.id}) this.taskService.create(task) @@ -191,7 +195,12 @@ }) }, loadTasksForPage(e) { - this.loadTasks(e.page) + // The page parameter can be undefined, in the case where the user loads a new list from the side bar menu + let page = e.page + if (typeof e.page === 'undefined') { + page = 1 + } + this.initTasks(page) }, markAsDone(e) { let updateFunc = () => {