Skip to content

Commit 328bcd0

Browse files
committed
feat(collections): display no children warning for empty presentations
1 parent ec76e9c commit 328bcd0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

apps/client/src/widgets/collections/presentation/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default function PresentationView({ note, noteIds, media, onReady }: View
4141
}
4242
}, [ api, presentation ]);
4343

44-
if (!presentation || !stylesheets) return;
44+
if (!presentation || !stylesheets || !note.hasChildren()) return;
4545
const content = (
4646
<>
4747
{stylesheets.map(stylesheet => <style>{stylesheet}</style>)}

apps/client/src/widgets/type_widgets/Book.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ import RawHtml from "../react/RawHtml";
55
import { TypeWidgetProps } from "./type_widget";
66
import "./Book.css";
77
import { useEffect, useState } from "preact/hooks";
8+
import { ViewTypeOptions } from "../collections/interface";
89

9-
const VIEW_TYPES = [ "list", "grid" ];
10+
const VIEW_TYPES: ViewTypeOptions[] = [ "list", "grid", "presentation" ];
1011

1112
export default function Book({ note }: TypeWidgetProps) {
1213
const [ viewType ] = useNoteLabelWithDefault(note, "viewType", "grid");
1314
const [ shouldDisplayNoChildrenWarning, setShouldDisplayNoChildrenWarning ] = useState(false);
1415

1516
function refresh() {
16-
setShouldDisplayNoChildrenWarning(!note.hasChildren() && VIEW_TYPES.includes(viewType ?? ""));
17+
setShouldDisplayNoChildrenWarning(!note.hasChildren() && VIEW_TYPES.includes(viewType as ViewTypeOptions));
1718
}
1819

1920
useEffect(refresh, [ note, viewType ]);

0 commit comments

Comments
 (0)