mirror of
https://github.com/zadam/trilium.git
synced 2025-11-21 16:14:23 +01:00
feat(collections): display no children warning for empty presentations
This commit is contained in:
parent
ec76e9cf2a
commit
328bcd0532
@ -41,7 +41,7 @@ export default function PresentationView({ note, noteIds, media, onReady }: View
|
|||||||
}
|
}
|
||||||
}, [ api, presentation ]);
|
}, [ api, presentation ]);
|
||||||
|
|
||||||
if (!presentation || !stylesheets) return;
|
if (!presentation || !stylesheets || !note.hasChildren()) return;
|
||||||
const content = (
|
const content = (
|
||||||
<>
|
<>
|
||||||
{stylesheets.map(stylesheet => <style>{stylesheet}</style>)}
|
{stylesheets.map(stylesheet => <style>{stylesheet}</style>)}
|
||||||
|
|||||||
@ -5,15 +5,16 @@ import RawHtml from "../react/RawHtml";
|
|||||||
import { TypeWidgetProps } from "./type_widget";
|
import { TypeWidgetProps } from "./type_widget";
|
||||||
import "./Book.css";
|
import "./Book.css";
|
||||||
import { useEffect, useState } from "preact/hooks";
|
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) {
|
export default function Book({ note }: TypeWidgetProps) {
|
||||||
const [ viewType ] = useNoteLabelWithDefault(note, "viewType", "grid");
|
const [ viewType ] = useNoteLabelWithDefault(note, "viewType", "grid");
|
||||||
const [ shouldDisplayNoChildrenWarning, setShouldDisplayNoChildrenWarning ] = useState(false);
|
const [ shouldDisplayNoChildrenWarning, setShouldDisplayNoChildrenWarning ] = useState(false);
|
||||||
|
|
||||||
function refresh() {
|
function refresh() {
|
||||||
setShouldDisplayNoChildrenWarning(!note.hasChildren() && VIEW_TYPES.includes(viewType ?? ""));
|
setShouldDisplayNoChildrenWarning(!note.hasChildren() && VIEW_TYPES.includes(viewType as ViewTypeOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(refresh, [ note, viewType ]);
|
useEffect(refresh, [ note, viewType ]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user