From 96f5b55d9fc5cf55a99bfca6c9234d70509f81c8 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 16 Oct 2025 09:02:02 +0300 Subject: [PATCH] refactor(collection/presentation): apply review suggestions --- .../collections/presentation/index.tsx | 4 +-- .../widgets/collections/presentation/model.ts | 27 +++++++------------ apps/client/src/widgets/react/ShadowDom.tsx | 4 +-- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/apps/client/src/widgets/collections/presentation/index.tsx b/apps/client/src/widgets/collections/presentation/index.tsx index 656940c68..7f40e8923 100644 --- a/apps/client/src/widgets/collections/presentation/index.tsx +++ b/apps/client/src/widgets/collections/presentation/index.tsx @@ -30,7 +30,6 @@ export default function PresentationView({ note, noteIds }: ViewModeProps<{}>) { useTriliumEvent("entitiesReloaded", ({ loadResults }) => { if (loadResults.getNoteIds().find(noteId => noteIds.includes(noteId))) { - console.log("Needs reload!"); refresh(); } }); @@ -105,7 +104,7 @@ function ButtonOverlay({ containerRef, api }: { containerRef: RefObject void }) { +function Presentation({ presentation, setApi } : { presentation: PresentationModel, setApi: (api: Reveal.Api | undefined) => void }) { const containerRef = useRef(null); const apiRef = useRef(null); const isFirstRenderRef = useRef(true); @@ -133,6 +132,7 @@ function Presentation({ presentation, setApi } : { presentation: PresentationMod return () => { api.destroy(); apiRef.current = null; + setApi(undefined); } }, [ ]); diff --git a/apps/client/src/widgets/collections/presentation/model.ts b/apps/client/src/widgets/collections/presentation/model.ts index a94ada59f..031ff2f36 100644 --- a/apps/client/src/widgets/collections/presentation/model.ts +++ b/apps/client/src/widgets/collections/presentation/model.ts @@ -19,17 +19,12 @@ export interface PresentationModel { } export async function buildPresentationModel(note: FNote): Promise { - const slideNotes = await note.getChildNotes(); - const slides: PresentationSlideModel[] = []; - - for (const slideNote of slideNotes) { - slides.push({ - noteId: slideNote.noteId, - content: await processContent(slideNote), - verticalSlides: await buildVerticalSlides(slideNote) - }) - } + const slides: PresentationSlideModel[] = await Promise.all(slideNotes.map(async slideNote => ({ + noteId: slideNote.noteId, + content: await processContent(slideNote), + verticalSlides: await buildVerticalSlides(slideNote) + }))) return { slides }; } @@ -38,13 +33,11 @@ async function buildVerticalSlides(parentSlideNote: FNote): Promise ({ + noteId: childNote.noteId, + content: await processContent(childNote) + }))); + return slides; } diff --git a/apps/client/src/widgets/react/ShadowDom.tsx b/apps/client/src/widgets/react/ShadowDom.tsx index 3bbd23427..7b98aba75 100644 --- a/apps/client/src/widgets/react/ShadowDom.tsx +++ b/apps/client/src/widgets/react/ShadowDom.tsx @@ -13,10 +13,10 @@ export default function ShadowDom({ children, containerRef: externalContainerRef // Create the shadow root. useEffect(() => { - if (!containerRef.current || shadowRoot) return; + if (!containerRef.current) return; const shadow = containerRef.current.attachShadow({ mode: "open" }); setShadowRoot(shadow); - }, [ shadowRoot ]); + }, []); // Render the child elements. useEffect(() => {