Skip to content

Commit

Permalink
update (useNote): small modification in format function, and update i…
Browse files Browse the repository at this point in the history
…n useNoteComposableState interface
  • Loading branch information
Madani Badaoui committed Nov 24, 2024
1 parent d9988fb commit 7baf8f1
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/application/services/useNote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ interface UseNoteComposableState {
*/
unlinkParent: () => Promise<void>;

/**
* Get the format of note parents
*/
formatNoteParents: () => Note[];

/**
* Defines if user can edit note
*/
Expand Down Expand Up @@ -284,13 +289,13 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt
}
let presentationFormat: Note[] = [];

if (noteParents.length > 2) {
presentationFormat = [noteParents[0]];
presentationFormat.push({ id: currentId.value,
content: note.value?.content as NoteContent });
if (noteParents.length === 0) {
presentationFormat.push({
id: currentId.value,
content: note.value?.content as NoteContent,
});
} else {
presentationFormat = [...noteParents, { id: currentId.value,
content: note.value?.content as NoteContent }];
presentationFormat = noteParents;
}

return presentationFormat;
Expand Down Expand Up @@ -364,6 +369,7 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt
resolveToolsByContent,
save,
unlinkParent,
formatNoteParents,
parentNote,
};
}

0 comments on commit 7baf8f1

Please sign in to comment.