mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02: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 appContext from "./app_context.js";
|
||||||
import treeService from "./tree.js";
|
import treeService from "./tree.js";
|
||||||
import dialogService from "../widgets/dialog.js";
|
import dialogService from "../widgets/dialog.js";
|
||||||
|
import froca from "./froca.js";
|
||||||
|
|
||||||
function getHoistedNoteId() {
|
function getHoistedNoteId() {
|
||||||
const activeNoteContext = appContext.tabManager.getActiveContext();
|
const activeNoteContext = appContext.tabManager.getActiveContext();
|
||||||
@ -26,6 +27,19 @@ function isHoistedNode(node) {
|
|||||||
|| node.data.noteId === getHoistedNoteId();
|
|| 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) {
|
async function checkNoteAccess(notePath, noteContext) {
|
||||||
const resolvedNotePath = await treeService.resolveNotePath(notePath, noteContext.hoistedNoteId);
|
const resolvedNotePath = await treeService.resolveNotePath(notePath, noteContext.hoistedNoteId);
|
||||||
|
|
||||||
@ -53,5 +67,6 @@ export default {
|
|||||||
unhoist,
|
unhoist,
|
||||||
isTopLevelNode,
|
isTopLevelNode,
|
||||||
isHoistedNode,
|
isHoistedNode,
|
||||||
checkNoteAccess
|
checkNoteAccess,
|
||||||
|
isHoistedInHiddenSubtree
|
||||||
}
|
}
|
||||||
|
@ -314,6 +314,10 @@ function parseNotePath(notePath) {
|
|||||||
return noteIds;
|
return noteIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isNotePathInHiddenSubtree(notePath) {
|
||||||
|
return notePath?.includes("root/hidden");
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
resolveNotePath,
|
resolveNotePath,
|
||||||
resolveNotePathToSegments,
|
resolveNotePathToSegments,
|
||||||
@ -328,5 +332,6 @@ export default {
|
|||||||
getNotePathTitle,
|
getNotePathTitle,
|
||||||
getNoteTitleWithPathAsSuffix,
|
getNoteTitleWithPathAsSuffix,
|
||||||
getHashValueFromAddress,
|
getHashValueFromAddress,
|
||||||
parseNotePath
|
parseNotePath,
|
||||||
|
isNotePathInHiddenSubtree
|
||||||
};
|
};
|
||||||
|
@ -964,7 +964,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
if (this.noteContext
|
if (this.noteContext
|
||||||
&& this.noteContext.notePath
|
&& this.noteContext.notePath
|
||||||
&& !this.noteContext.note?.isDeleted
|
&& !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);
|
const newActiveNode = await this.getNodeFromPath(this.noteContext.notePath);
|
||||||
|
|
||||||
@ -1058,7 +1058,9 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
const noteIdsToReload = new Set();
|
const noteIdsToReload = new Set();
|
||||||
|
|
||||||
for (const ecAttr of loadResults.getAttributes()) {
|
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) {
|
if (ecAttr.isInheritable) {
|
||||||
noteIdsToReload.add(ecAttr.noteId);
|
noteIdsToReload.add(ecAttr.noteId);
|
||||||
}
|
}
|
||||||
@ -1169,7 +1171,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
let node = await this.expandToNote(activeNotePath, false);
|
let node = await this.expandToNote(activeNotePath, false);
|
||||||
|
|
||||||
if (node && node.data.noteId !== activeNoteId) {
|
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
|
// so we switch to the alternative of trying to find it by noteId
|
||||||
const notesById = this.getNodesByNoteId(activeNoteId);
|
const notesById = this.getNodesByNoteId(activeNoteId);
|
||||||
|
|
||||||
@ -1186,7 +1188,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
await node.setActive(true, {noEvents: true, noFocus: !activeNodeFocused});
|
await node.setActive(true, {noEvents: true, noFocus: !activeNodeFocused});
|
||||||
}
|
}
|
||||||
else {
|
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);
|
node = await this.expandToNote(nextNotePath, false);
|
||||||
|
|
||||||
if (node) {
|
if (node) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user