Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(collections): display no children warning for empty presentations
Elian Doran328bcd053222
diff --git a/apps/client/src/widgets/collections/presentation/index.tsx b/apps/client/src/widgets/collections/presentation/index.tsxindex dfa4574e0b..ca236a46ce 100644--- a/apps/client/src/widgets/collections/presentation/index.tsx+++ b/apps/client/src/widgets/collections/presentation/index.tsx@@ -41,7 +41,7 @@ export default function PresentationView({ note, noteIds, media, onReady }: View}}, [ api, presentation ]);- if (!presentation || !stylesheets) return;+ if (!presentation || !stylesheets || !note.hasChildren()) return;const content = (<>{stylesheets.map(stylesheet => <style>{stylesheet}</style>)}diff --git a/apps/client/src/widgets/type_widgets/Book.tsx b/apps/client/src/widgets/type_widgets/Book.tsxindex 6b796f6b6f..8dd1030c5d 100644--- a/apps/client/src/widgets/type_widgets/Book.tsx+++ b/apps/client/src/widgets/type_widgets/Book.tsx@@ -5,15 +5,16 @@ import RawHtml from "../react/RawHtml";import { TypeWidgetProps } from "./type_widget";import "./Book.css";import { useEffect, useState } from "preact/hooks";+import { ViewTypeOptions } from "../collections/interface";-const VIEW_TYPES = [ "list", "grid" ];+const VIEW_TYPES: ViewTypeOptions[] = [ "list", "grid", "presentation" ];export default function Book({ note }: TypeWidgetProps) {const [ viewType ] = useNoteLabelWithDefault(note, "viewType", "grid");const [ shouldDisplayNoChildrenWarning, setShouldDisplayNoChildrenWarning ] = useState(false);function refresh() {- setShouldDisplayNoChildrenWarning(!note.hasChildren() && VIEW_TYPES.includes(viewType ?? ""));+ setShouldDisplayNoChildrenWarning(!note.hasChildren() && VIEW_TYPES.includes(viewType as ViewTypeOptions));}useEffect(refresh, [ note, viewType ]);