From 328bcd053222d20ab6c72fad37f1f026bb728a60 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 18 Nov 2025 08:51:47 +0200 Subject: [PATCH] feat(collections): display no children warning for empty presentations --- apps/client/src/widgets/collections/presentation/index.tsx | 2 +- apps/client/src/widgets/type_widgets/Book.tsx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/client/src/widgets/collections/presentation/index.tsx b/apps/client/src/widgets/collections/presentation/index.tsx index dfa4574e0..ca236a46c 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 => )} diff --git a/apps/client/src/widgets/type_widgets/Book.tsx b/apps/client/src/widgets/type_widgets/Book.tsx index 6b796f6b6..8dd1030c5 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 ]);