Skip to content

Build your personal knowledge base with Trilium Notes

feat(in-app-help): hide notes that are hidden from share

Elian Doran8aaf2367e9d6
diff --git a/src/services/in_app_help.spec.ts b/src/services/in_app_help.spec.ts
index a716be4ed6..2871fc16b5 100644
--- a/src/services/in_app_help.spec.ts
+++ b/src/services/in_app_help.spec.ts
@@ -30,7 +30,37 @@ describe("In-app help", () => {
};
const item = parseNoteMeta(meta, "/");
- const icon = item.attributes?.find((a) => a.name === "iconClass");
+ const icon = item?.attributes?.find((a) => a.name === "iconClass");
expect(icon?.value).toBe("bx bx-star");
});
+
+ it("hides note that is hidden from share tree", () => {
+ const meta: NoteMeta = {
+ isClone: false,
+ noteId: "yoAe4jV2yzbd",
+ notePath: ["OkOZllzB3fqN", "yoAe4jV2yzbd"],
+ title: "Features",
+ notePosition: 40,
+ prefix: null,
+ isExpanded: false,
+ type: "text",
+ mime: "text/html",
+ attributes: [
+ {
+ type: "label",
+ name: "shareHiddenFromTree",
+ value: "",
+ isInheritable: false,
+ position: 10
+ }
+ ],
+ format: "html",
+ attachments: [],
+ dirFileName: "Features",
+ children: []
+ };
+
+ const item = parseNoteMeta(meta, "/");
+ expect(item).toBeFalsy();
+ });
});
diff --git a/src/services/in_app_help.ts b/src/services/in_app_help.ts
index 7841ee71b1..a2322ab753 100644
--- a/src/services/in_app_help.ts
+++ b/src/services/in_app_help.ts
@@ -25,15 +25,16 @@ export function getHelpHiddenSubtreeData() {
function parseNoteMetaFile(noteMetaFile: NoteMetaFile): HiddenSubtreeItem[] {
if (!noteMetaFile.files) {
+ console.log("No meta files");
return [];
}
const metaRoot = noteMetaFile.files[0];
const parsedMetaRoot = parseNoteMeta(metaRoot, "/" + (metaRoot.dirFileName ?? ""));
- return parsedMetaRoot.children ?? [];
+ return parsedMetaRoot?.children ?? [];
}
-export function parseNoteMeta(noteMeta: NoteMeta, docNameRoot: string): HiddenSubtreeItem {
+export function parseNoteMeta(noteMeta: NoteMeta, docNameRoot: string): HiddenSubtreeItem | null {
let iconClass: string = "bx bx-file";
const item: HiddenSubtreeItem = {
id: `_help_${noteMeta.noteId}`,
@@ -62,6 +63,10 @@ export function parseNoteMeta(noteMeta: NoteMeta, docNameRoot: string): HiddenSu
value: attribute.value
});
}
+
+ if (attribute.name === "shareHiddenFromTree") {
+ return null;
+ }
}
// Handle text notes
@@ -84,7 +89,10 @@ export function parseNoteMeta(noteMeta: NoteMeta, docNameRoot: string): HiddenSu
const children: HiddenSubtreeItem[] = [];
for (const childMeta of noteMeta.children) {
let newDocNameRoot = noteMeta.dirFileName ? `${docNameRoot}/${noteMeta.dirFileName}` : docNameRoot;
- children.push(parseNoteMeta(childMeta, newDocNameRoot));
+ const item = parseNoteMeta(childMeta, newDocNameRoot);
+ if (item) {
+ children.push(item);
+ }
}
item.children = children;