From 384d8c9c37b8e3f5d666e0c1dcf9aef3476c122b Mon Sep 17 00:00:00 2001 From: Jakob Schlanstedt Date: Sun, 12 Oct 2025 18:54:39 +0200 Subject: [PATCH] refactor(note-create): change order of noteCreate intoPath and intoInbox to improve code compatibility --- apps/client/src/services/note_create.ts | 59 +++++++++++++------------ 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/apps/client/src/services/note_create.ts b/apps/client/src/services/note_create.ts index 9abd0573d..785db66d9 100644 --- a/apps/client/src/services/note_create.ts +++ b/apps/client/src/services/note_create.ts @@ -39,35 +39,6 @@ interface DuplicateResponse { note: FNote; } -/** - * Creates a new note inside the user's Inbox. - * - * @param {CreateNoteOpts} [options] - Optional settings such as title, type, template, or content. - * @returns {Promise<{ note: FNote | null; branch: FBranch | undefined }>} - * Resolves with the created note and its branch, or `{ note: null, branch: undefined }` if the inbox is missing. - */ -async function createNoteIntoInbox( - options: CreateNoteOpts = {} -): Promise<{ note: FNote | null; branch: FBranch | undefined }> { - const inboxNote = await dateNoteService.getInboxNote(); - if (!inboxNote) { - console.warn("Missing inbox note."); - // always return a defined object - return { note: null, branch: undefined }; - } - - if (options.isProtected === undefined) { - options.isProtected = - inboxNote.isProtected && protectedSessionHolder.isProtectedSessionAvailable(); - } - - const result = await createNoteIntoPath(inboxNote.noteId, { - ...options, - target: "into", - }); - - return result; -} /** * Core function that creates a new note under the specified parent note path. * @@ -149,6 +120,36 @@ async function createNoteIntoPath( }; } +/** + * Creates a new note inside the user's Inbox. + * + * @param {CreateNoteOpts} [options] - Optional settings such as title, type, template, or content. + * @returns {Promise<{ note: FNote | null; branch: FBranch | undefined }>} + * Resolves with the created note and its branch, or `{ note: null, branch: undefined }` if the inbox is missing. + */ +async function createNoteIntoInbox( + options: CreateNoteOpts = {} +): Promise<{ note: FNote | null; branch: FBranch | undefined }> { + const inboxNote = await dateNoteService.getInboxNote(); + if (!inboxNote) { + console.warn("Missing inbox note."); + // always return a defined object + return { note: null, branch: undefined }; + } + + if (options.isProtected === undefined) { + options.isProtected = + inboxNote.isProtected && protectedSessionHolder.isProtectedSessionAvailable(); + } + + const result = await createNoteIntoPath(inboxNote.noteId, { + ...options, + target: "into", + }); + + return result; +} + async function chooseNoteType() { return new Promise((res) => { appContext.triggerCommand("chooseNoteType", { callback: res });