From 5d8ca1ecf7ba443b4c101dcf723e72520d45f943 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 16 Oct 2025 15:32:16 +0300 Subject: [PATCH] chore(collection/presentation): address requested changes --- apps/client/src/components/note_context.ts | 2 +- .../widgets/collections/presentation/index.tsx | 18 +++++++----------- .../widgets/collections/presentation/themes.ts | 7 +------ apps/server/src/services/hidden_subtree.ts | 6 +++--- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/apps/client/src/components/note_context.ts b/apps/client/src/components/note_context.ts index 4b77e4965..79d1e148b 100644 --- a/apps/client/src/components/note_context.ts +++ b/apps/client/src/components/note_context.ts @@ -439,7 +439,7 @@ class NoteContext extends Component implements EventListener<"entitiesReloaded"> } export function openInCurrentNoteContext(evt: MouseEvent | JQuery.ClickEvent | JQuery.MouseDownEvent | React.PointerEvent | null, notePath: string, viewScope?: ViewScope) { - const ntxId = $(evt?.target as any) + const ntxId = $(evt?.target as Element) .closest("[data-ntx-id]") .attr("data-ntx-id"); diff --git a/apps/client/src/widgets/collections/presentation/index.tsx b/apps/client/src/widgets/collections/presentation/index.tsx index 6c8e530ff..1d9896d35 100644 --- a/apps/client/src/widgets/collections/presentation/index.tsx +++ b/apps/client/src/widgets/collections/presentation/index.tsx @@ -119,11 +119,10 @@ function ButtonOverlay({ containerRef, api }: { containerRef: RefObject void }) { const containerRef = useRef(null); - const apiRef = useRef(null); - const isFirstRenderRef = useRef(true); + const [revealApi, setRevealApi] = useState(); useEffect(() => { - if (apiRef.current || !containerRef.current) return; + if (!containerRef.current) return; const api = new Reveal(containerRef.current, { transition: "slide", @@ -138,23 +137,20 @@ function Presentation({ presentation, setApi } : { presentation: PresentationMod }, }); api.initialize().then(() => { - apiRef.current = api; + setRevealApi(revealApi); setApi(api); }); return () => { api.destroy(); - apiRef.current = null; + setRevealApi(undefined); setApi(undefined); } - }, [ ]); + }, []); useEffect(() => { - if (!isFirstRenderRef.current) { - apiRef.current?.sync(); - } - isFirstRenderRef.current = false; - }, [ presentation ]); + revealApi?.sync(); + }, [ presentation, revealApi ]); return (
diff --git a/apps/client/src/widgets/collections/presentation/themes.ts b/apps/client/src/widgets/collections/presentation/themes.ts index a5422cef5..da706a658 100644 --- a/apps/client/src/widgets/collections/presentation/themes.ts +++ b/apps/client/src/widgets/collections/presentation/themes.ts @@ -1,11 +1,6 @@ export const DEFAULT_THEME = "white"; -interface ThemeDefinition { - name: string; - loadTheme: () => Promise; -} - -const themes: Record = { +const themes = { black: { name: "Black", loadTheme: () => import("reveal.js/dist/theme/black.css?raw") diff --git a/apps/server/src/services/hidden_subtree.ts b/apps/server/src/services/hidden_subtree.ts index 547251818..1013d16fc 100644 --- a/apps/server/src/services/hidden_subtree.ts +++ b/apps/server/src/services/hidden_subtree.ts @@ -359,7 +359,7 @@ function checkHiddenSubtreeRecursively(parentNoteId: string, item: HiddenSubtree branch = note.getParentBranches().find((branch) => branch.parentNoteId === parentNoteId); if (item.content && note.getContent() !== item.content) { - console.log(`Updating content of ${item.id}.`); + log.info(`Updating content of ${item.id}.`); note.setContent(item.content); } @@ -369,7 +369,7 @@ function checkHiddenSubtreeRecursively(parentNoteId: string, item: HiddenSubtree // If the note exists but doesn't have a branch in the expected parent, // create the missing branch to ensure it's in the correct location if (!branch) { - console.log("Creating missing branch for note", item.id, "under parent", parentNoteId); + log.info(`Creating missing branch for note ${item.id} under parent ${parentNoteId}.`); branch = new BBranch({ noteId: item.id, parentNoteId: parentNoteId, @@ -473,7 +473,7 @@ function checkHiddenSubtreeRecursively(parentNoteId: string, item: HiddenSubtree }).save(); } else if (attr.name === "docName" || (existingAttribute.noteId.startsWith("_help") && attr.name === "iconClass")) { if (existingAttribute.value !== attr.value) { - console.log(`Updating attribute ${attrId} from "${existingAttribute.value}" to "${attr.value}"`); + log.info(`Updating attribute ${attrId} from "${existingAttribute.value}" to "${attr.value}"`); existingAttribute.value = attr.value ?? ""; existingAttribute.save(); }