mirror of
https://github.com/zadam/trilium.git
synced 2025-10-19 22:58:52 +02:00
refactor(collection/presentation): apply review suggestions
This commit is contained in:
parent
90e5193a97
commit
96f5b55d9f
@ -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<HTMLDivE
|
||||
)
|
||||
}
|
||||
|
||||
function Presentation({ presentation, setApi } : { presentation: PresentationModel, setApi: (api: Reveal.Api) => void }) {
|
||||
function Presentation({ presentation, setApi } : { presentation: PresentationModel, setApi: (api: Reveal.Api | undefined) => void }) {
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const apiRef = useRef<Reveal.Api>(null);
|
||||
const isFirstRenderRef = useRef(true);
|
||||
@ -133,6 +132,7 @@ function Presentation({ presentation, setApi } : { presentation: PresentationMod
|
||||
return () => {
|
||||
api.destroy();
|
||||
apiRef.current = null;
|
||||
setApi(undefined);
|
||||
}
|
||||
}, [ ]);
|
||||
|
||||
|
@ -19,17 +19,12 @@ export interface PresentationModel {
|
||||
}
|
||||
|
||||
export async function buildPresentationModel(note: FNote): Promise<PresentationModel> {
|
||||
|
||||
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<undefined |
|
||||
const children = await parentSlideNote.getChildNotes();
|
||||
if (!children.length) return;
|
||||
|
||||
const slides: PresentationSlideBaseModel[] = [];
|
||||
for (const childNote of children) {
|
||||
slides.push({
|
||||
noteId: childNote.noteId,
|
||||
content: await processContent(childNote)
|
||||
});
|
||||
}
|
||||
const slides: PresentationSlideBaseModel[] = await Promise.all(children.map(async childNote => ({
|
||||
noteId: childNote.noteId,
|
||||
content: await processContent(childNote)
|
||||
})));
|
||||
|
||||
return slides;
|
||||
}
|
||||
|
||||
|
@ -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(() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user