Skip to content

Commit 42be923

Browse files
fix(useNote): update note's content & parents on create
1 parent 8ef87f4 commit 42be923

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

src/application/services/useNote.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { onMounted, ref, type Ref, type MaybeRefOrGetter, computed, toValue, watch } from 'vue';
2-
import { noteService, editorToolsService } from '@/domain';
3-
import type { Note, NoteContent, NoteId } from '@/domain/entities/Note';
4-
import type { NoteTool } from '@/domain/entities/Note';
5-
import { useRouter, useRoute } from 'vue-router';
1+
import { computed, type MaybeRefOrGetter, onMounted, ref, type Ref, toValue, watch } from 'vue';
2+
import { editorToolsService, noteService } from '@/domain';
3+
import type { Note, NoteContent, NoteId, NoteTool } from '@/domain/entities/Note';
4+
import { useRoute, useRouter } from 'vue-router';
65
import type { NoteDraft } from '@/domain/entities/NoteDraft';
76
import type EditorTool from '@/domain/entities/EditorTool';
87
import DomainError from '@/domain/entities/errors/Base';
@@ -188,9 +187,7 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt
188187
* @param id - note id
189188
*/
190189
async function getNoteHierarchy(id: NoteId): Promise<void> {
191-
let response = await noteService.getNoteHierarchy(id);
192-
193-
noteHierarchy.value = response;
190+
noteHierarchy.value = await noteService.getNoteHierarchy(id);
194191
}
195192

196193
/**
@@ -255,6 +252,7 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt
255252
*/
256253
const specifiedNoteTools = resolveToolsByContent(content);
257254

255+
note.value.content = content;
258256
isNoteSaving.value = true;
259257

260258
if (currentId.value === null) {
@@ -263,6 +261,7 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt
263261
*/
264262
const noteCreated = await noteService.createNote(content, specifiedNoteTools, parentId);
265263

264+
noteParents.value = (await noteService.getNoteById(noteCreated.id)).parents;
266265
/**
267266
* Replace the current route with note id
268267
*/

0 commit comments

Comments
 (0)