From 4ecb5c2dc5db12b1ffa57953de96f1e63222ac9f Mon Sep 17 00:00:00 2001 From: 7eliassen Date: Wed, 7 Oct 2026 16:20:00 +0300 Subject: [PATCH] fix: use watch instead of onMounted to load notes settings page --- src/application/services/useNoteSettings.ts | 3 +++ src/presentation/pages/NoteSettings.vue | 12 +++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/application/services/useNoteSettings.ts b/src/application/services/useNoteSettings.ts index bd488b3a..13798036 100644 --- a/src/application/services/useNoteSettings.ts +++ b/src/application/services/useNoteSettings.ts @@ -102,6 +102,9 @@ export default function (): UseNoteSettingsComposableState { * @param id - Note id */ const load = async (id: NoteId): Promise => { + noteSettings.value = null; + parentNote.value = undefined; + noteSettings.value = await noteSettingsService.getNoteSettingsById(id); const response = await noteService.getNoteById(id); diff --git a/src/presentation/pages/NoteSettings.vue b/src/presentation/pages/NoteSettings.vue index f2cbccc6..8d97be15 100644 --- a/src/presentation/pages/NoteSettings.vue +++ b/src/presentation/pages/NoteSettings.vue @@ -103,7 +103,7 @@ import useNoteSettings from '@/application/services/useNoteSettings'; import useNote from '@/application/services/useNote'; import { useHead } from 'unhead'; import { useI18n } from 'vue-i18n'; -import { computed, ref, onMounted, watch } from 'vue'; +import { computed, ref, watch } from 'vue'; import { useDebounceFn } from '@vueuse/core'; import Team from '@/presentation/components/team/Team.vue'; import { Section, Row, Switch, Button, Heading, Fieldset, Input, Card, PageBlock } from '@codexteam/ui/vue'; @@ -127,7 +127,7 @@ const { patchOpenedPageByUrl } = useNavbar(); const route = useRoute(); const { noteSettings, load: loadSettings, updateIsPublic, deleteNoteById, parentNote, setParent } = useNoteSettings(); const { noteTitle, unlinkParent } = useNote({ - id: props.id, + id: () => props.id, }); /** @@ -218,10 +218,12 @@ watch(noteTitle, (newTitle) => { patchOpenedPageByUrl(route.path, openPageInfo); }); -onMounted(async () => { - await loadSettings(props.id); +watch(() => props.id, async (id) => { + parentURL.value = ''; + await loadSettings(id); + parentURL.value = getParentURL(parentNote.value?.id); -}); +}, { immediate: true }); /** * Handle team member removal by refreshing the note settings and removing the member from the team