From aadf75c7bffc3ffc5367d7a126905b7a3f8b4a1c Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 12 Jun 2022 14:59:53 +0200 Subject: [PATCH] fix: don't try to load the namespace again when navigating away from the settings page Resolves https://github.com/go-vikunja/frontend/issues/58 --- src/router/index.ts | 1 + src/views/namespaces/settings/edit.vue | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index 4a7f2c4f2..69795df67 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -217,6 +217,7 @@ const router = createRouter({ meta: { showAsModal: true, }, + props: route => ({ namespaceId: parseInt(route.params.id as string) }), }, { path: '/namespaces/:namespaceId/settings/share', diff --git a/src/views/namespaces/settings/edit.vue b/src/views/namespaces/settings/edit.vue index 5336c5ef8..136ce63bb 100644 --- a/src/views/namespaces/settings/edit.vue +++ b/src/views/namespaces/settings/edit.vue @@ -82,14 +82,16 @@ export default defineComponent({ Fancycheckbox, editor: AsyncEditor, }, - beforeMount() { - this.namespace.id = this.$route.params.id + props: { + namespaceId: { + type: Number, + required: true, + }, }, watch: { // call again the method if the route changes - '$route': { + namespaceId: { handler: 'loadNamespace', - deep: true, immediate: true, }, }, @@ -103,8 +105,7 @@ export default defineComponent({ this.editorActive = false this.$nextTick(() => this.editorActive = true) - const namespace = new NamespaceModel({id: this.$route.params.id}) - this.namespace = await this.namespaceService.get(namespace) + this.namespace = await this.namespaceService.get({id: this.namespaceId}) // This will trigger the dynamic loading of components once we actually have all the data to pass to them this.manageTeamsComponent = 'manageSharing' this.manageUsersComponent = 'manageSharing'