mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-11-02 05:51:30 +08:00
feat(in-app-help): hide notes that are hidden from share
This commit is contained in:
parent
6f799692e0
commit
8aaf2367e9
@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user