Skip to content

Build your personal knowledge base with Trilium Notes

chore(collection/presentation): don't sync on first render

Elian Doranf33fe4266afc
diff --git a/apps/client/src/widgets/collections/presentation/index.tsx b/apps/client/src/widgets/collections/presentation/index.tsx
index 856947e417..b384b02208 100644
--- a/apps/client/src/widgets/collections/presentation/index.tsx
+++ b/apps/client/src/widgets/collections/presentation/index.tsx
@@ -68,6 +68,7 @@ function ButtonOverlay({ containerRef, apiRef }: { containerRef: RefObject<HTMLD
function Presentation({ presentation, apiRef: externalApiRef } : { presentation: PresentationModel, apiRef: RefObject<Reveal.Api> }) {
const containerRef = useRef<HTMLDivElement>(null);
const apiRef = useRef<Reveal.Api>(null);
+ const isFirstRenderRef = useRef(true);
useEffect(() => {
if (apiRef.current || !containerRef.current) return;
@@ -96,7 +97,10 @@ function Presentation({ presentation, apiRef: externalApiRef } : { presentation:
}, [ ]);
useEffect(() => {
- apiRef.current?.sync();
+ if (!isFirstRenderRef.current) {
+ apiRef.current?.sync();
+ }
+ isFirstRenderRef.current = false;
}, [ presentation ]);
return (