From 64abb1ce379c3400357cf0bbb7595cf5682f2e11 Mon Sep 17 00:00:00 2001 From: dpschen Date: Sat, 2 Oct 2021 13:33:01 +0000 Subject: [PATCH] feat: watch taskId instead of whole route (#812) Co-authored-by: Dominik Pschenitschni Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/812 Reviewed-by: konrad Co-authored-by: dpschen Co-committed-by: dpschen --- src/views/tasks/TaskDetailView.vue | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/views/tasks/TaskDetailView.vue b/src/views/tasks/TaskDetailView.vue index 653af154..6635097b 100644 --- a/src/views/tasks/TaskDetailView.vue +++ b/src/views/tasks/TaskDetailView.vue @@ -471,7 +471,6 @@ export default { }, data() { return { - taskId: Number(this.$route.params.id), taskService: new TaskService(), task: new TaskModel(), relationKinds: relationKinds, @@ -507,13 +506,16 @@ export default { } }, watch: { - '$route': { + taskId: { handler: 'loadTask', - deep: true, immediate: true, }, }, computed: { + taskId() { + const { id } = this.$route.params + return id === undefined ? id : Number(id) + }, currentList() { return this.$store.state[CURRENT_LIST] }, @@ -557,9 +559,12 @@ export default { return uploadFile(this.taskId, ...args) }, - loadTask() { - this.taskId = Number(this.$route.params.id) - this.taskService.get({id: this.taskId}) + loadTask(taskId) { + if (taskId === undefined) { + return + } + + this.taskService.get({id: taskId}) .then(r => { this.$set(this, 'task', r) this.$store.commit('attachments/set', r.attachments)