mirror of
https://github.com/zadam/trilium.git
synced 2024-09-22 16:46:09 +08:00
fix activating notes in the hidden subtree
This commit is contained in:
parent
7e83d3a54d
commit
4f1f632a7d
|
@ -1,6 +1,7 @@
|
|||
import appContext from "./app_context.js";
|
||||
import treeService from "./tree.js";
|
||||
import dialogService from "../widgets/dialog.js";
|
||||
import froca from "./froca.js";
|
||||
|
||||
function getHoistedNoteId() {
|
||||
const activeNoteContext = appContext.tabManager.getActiveContext();
|
||||
|
@ -26,6 +27,19 @@ function isHoistedNode(node) {
|
|||
|| node.data.noteId === getHoistedNoteId();
|
||||
}
|
||||
|
||||
async function isHoistedInHiddenSubtree() {
|
||||
const hoistedNoteId = getHoistedNoteId();
|
||||
|
||||
if (hoistedNoteId === 'root') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const hoistedNote = await froca.getNote(hoistedNoteId);
|
||||
const hoistedNotePath = treeService.getSomeNotePath(hoistedNote);
|
||||
|
||||
return treeService.isNotePathInHiddenSubtree(hoistedNotePath);
|
||||
}
|
||||
|
||||
async function checkNoteAccess(notePath, noteContext) {
|
||||
const resolvedNotePath = await treeService.resolveNotePath(notePath, noteContext.hoistedNoteId);
|
||||
|
||||
|
@ -53,5 +67,6 @@ export default {
|
|||
unhoist,
|
||||
isTopLevelNode,
|
||||
isHoistedNode,
|
||||
checkNoteAccess
|
||||
checkNoteAccess,
|
||||
isHoistedInHiddenSubtree
|
||||
}
|
||||
|
|
|
@ -314,6 +314,10 @@ function parseNotePath(notePath) {
|
|||
return noteIds;
|
||||
}
|
||||
|
||||
function isNotePathInHiddenSubtree(notePath) {
|
||||
return notePath?.includes("root/hidden");
|
||||
}
|
||||
|
||||
export default {
|
||||
resolveNotePath,
|
||||
resolveNotePathToSegments,
|
||||
|
@ -328,5 +332,6 @@ export default {
|
|||
getNotePathTitle,
|
||||
getNoteTitleWithPathAsSuffix,
|
||||
getHashValueFromAddress,
|
||||
parseNotePath
|
||||
parseNotePath,
|
||||
isNotePathInHiddenSubtree
|
||||
};
|
||||
|
|
|
@ -964,7 +964,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||
if (this.noteContext
|
||||
&& this.noteContext.notePath
|
||||
&& !this.noteContext.note?.isDeleted
|
||||
&& !this.noteContext.notePath.includes("root/hidden")
|
||||
&& (!treeService.isNotePathInHiddenSubtree(this.noteContext.notePath) || await hoistedNoteService.isHoistedInHiddenSubtree())
|
||||
) {
|
||||
const newActiveNode = await this.getNodeFromPath(this.noteContext.notePath);
|
||||
|
||||
|
@ -1058,7 +1058,9 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||
const noteIdsToReload = new Set();
|
||||
|
||||
for (const ecAttr of loadResults.getAttributes()) {
|
||||
if (ecAttr.type === 'label' && ['iconClass', 'cssClass', 'workspace', 'workspaceIconClass', 'archived', 'color'].includes(ecAttr.name)) {
|
||||
const dirtyingLabels = ['iconClass', 'cssClass', 'workspace', 'workspaceIconClass', 'archived', 'color'];
|
||||
|
||||
if (ecAttr.type === 'label' && dirtyingLabels.includes(ecAttr.name)) {
|
||||
if (ecAttr.isInheritable) {
|
||||
noteIdsToReload.add(ecAttr.noteId);
|
||||
}
|
||||
|
@ -1169,7 +1171,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||
let node = await this.expandToNote(activeNotePath, false);
|
||||
|
||||
if (node && node.data.noteId !== activeNoteId) {
|
||||
// if the active note has been moved elsewhere then it won't be found by the path
|
||||
// if the active note has been moved elsewhere then it won't be found by the path,
|
||||
// so we switch to the alternative of trying to find it by noteId
|
||||
const notesById = this.getNodesByNoteId(activeNoteId);
|
||||
|
||||
|
@ -1186,7 +1188,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||
await node.setActive(true, {noEvents: true, noFocus: !activeNodeFocused});
|
||||
}
|
||||
else {
|
||||
// this is used when original note has been deleted and we want to move the focus to the note above/below
|
||||
// this is used when original note has been deleted, and we want to move the focus to the note above/below
|
||||
node = await this.expandToNote(nextNotePath, false);
|
||||
|
||||
if (node) {
|
||||
|
|
Loading…
Reference in a new issue