Skip to content

Commit 85ad2c5

Browse files
Jakob Schlanstedtwerererer
authored andcommitted
fix(note-autocomplete): logic error hidden by as typecast
1 parent 437763e commit 85ad2c5

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

apps/client/src/services/note_autocomplete.ts

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -480,24 +480,38 @@ function initNoteAutocomplete($el: JQuery<HTMLElement>, options?: Options) {
480480
}
481481

482482
case SuggestionAction.CreateNoteIntoInbox:
483-
case SuggestionAction.CreateAndLinkNoteIntoInbox:
483+
case SuggestionAction.CreateAndLinkNoteIntoInbox: {
484+
const { note } = await noteCreateService.createNote(
485+
{
486+
target: "inbox",
487+
title: suggestion.noteTitle,
488+
activate: true,
489+
promptForType: true,
490+
} as CreateNoteIntoInboxOpts
491+
);
492+
493+
if (!note) return;
494+
495+
const hoistedNoteId = appContext.tabManager.getActiveContext()?.hoistedNoteId;
496+
suggestion.notePath = note?.getBestNotePathString(hoistedNoteId);
497+
498+
$el.trigger("autocomplete:noteselected", [suggestion]);
499+
$el.autocomplete("close");
500+
break;
501+
}
502+
484503
case SuggestionAction.CreateNoteIntoPath:
485504
case SuggestionAction.CreateAndLinkNoteIntoPath: {
486-
let target = "inbox";
487-
if (
488-
suggestion.action === SuggestionAction.CreateNoteIntoPath ||
489-
suggestion.action === SuggestionAction.CreateAndLinkNoteIntoPath
490-
) {
491-
target = "into";
492-
}
505+
if (!suggestion.parentNoteId) return;
493506

494507
const { note } = await noteCreateService.createNote(
495508
{
496-
target: target,
509+
parentNoteUrl: suggestion.parentNoteId,
510+
target: "into",
497511
title: suggestion.noteTitle,
498512
activate: true,
499513
promptForType: true,
500-
} as CreateNoteIntoInboxOpts
514+
},
501515
);
502516

503517
if (!note) return;

0 commit comments

Comments
 (0)