From bf4776a33c38403996f1b19390c5753c580886c8 Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 8 Nov 2022 22:19:16 +0100 Subject: [PATCH] note hoisting should be done on "hovered", not active note, closes #2124 --- src/public/app/services/entrypoints.js | 14 ++++++++------ src/public/app/services/tree_context_menu.js | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/public/app/services/entrypoints.js b/src/public/app/services/entrypoints.js index 116877976..e18691c0f 100644 --- a/src/public/app/services/entrypoints.js +++ b/src/public/app/services/entrypoints.js @@ -7,6 +7,7 @@ import Component from "../widgets/component.js"; import toastService from "./toast.js"; import ws from "./ws.js"; import bundleService from "./bundle.js"; +import froca from "./froca.js"; export default class Entrypoints extends Component { constructor() { @@ -46,14 +47,15 @@ export default class Entrypoints extends Component { appContext.triggerEvent('focusAndSelectTitle', {isNewNote: true}); } - async toggleNoteHoistingCommand() { - const noteContext = appContext.tabManager.getActiveContext(); + async toggleNoteHoistingCommand({noteId = appContext.tabManager.getActiveContextNoteId()}) { + const noteToHoist = await froca.getNote(noteId); + const activeNoteContext = appContext.tabManager.getActiveContext(); - if (noteContext.note.noteId === noteContext.hoistedNoteId) { - await noteContext.unhoist(); + if (noteToHoist.noteId === activeNoteContext.hoistedNoteId) { + await activeNoteContext.unhoist(); } - else if (noteContext.note.type !== 'search') { - await noteContext.setHoistedNoteId(noteContext.note.noteId); + else if (noteToHoist.type !== 'search') { + await activeNoteContext.setHoistedNoteId(noteId); } } diff --git a/src/public/app/services/tree_context_menu.js b/src/public/app/services/tree_context_menu.js index cafb08ab7..f9843f8c4 100644 --- a/src/public/app/services/tree_context_menu.js +++ b/src/public/app/services/tree_context_menu.js @@ -133,6 +133,7 @@ class TreeContextMenu { this.treeWidget.triggerCommand(command, { node: this.node, notePath: notePath, + noteId: this.node.data.noteId, selectedOrActiveBranchIds: this.treeWidget.getSelectedOrActiveBranchIds(this.node), selectedOrActiveNoteIds: this.treeWidget.getSelectedOrActiveNoteIds(this.node) });