From 29f789493e547ef090ed9a7040f1ac49c7221098 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Fri, 16 Jan 2026 12:41:12 +0500 Subject: [PATCH] web: fix previewing note history where only title has changed --- apps/web/src/components/diff-viewer/index.tsx | 370 +++++++++--------- apps/web/src/stores/editor-store.ts | 15 +- 2 files changed, 202 insertions(+), 183 deletions(-) diff --git a/apps/web/src/components/diff-viewer/index.tsx b/apps/web/src/components/diff-viewer/index.tsx index c411194d4..724e09722 100644 --- a/apps/web/src/components/diff-viewer/index.tsx +++ b/apps/web/src/components/diff-viewer/index.tsx @@ -17,13 +17,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -import { - useCallback, - useEffect, - useLayoutEffect, - useRef, - useState -} from "react"; +import { useCallback, useEffect, useLayoutEffect, useState } from "react"; import { Flex, Text, Button } from "@theme-ui/components"; import { Copy, Restore } from "../icons"; import ContentToggle from "./content-toggle"; @@ -59,6 +53,8 @@ function DiffViewer(props: DiffViewerProps) { const onResolveContent = useCallback( (saveCopy: boolean) => { + if (!conflictedContent) return; + const toKeep = selectedContent === 1 ? session.content?.conflicted : session.content; const toCopy = @@ -69,7 +65,7 @@ function DiffViewer(props: DiffViewerProps) { toKeep, toCopy: saveCopy ? toCopy : undefined, toKeepDateEdited: toKeep.dateEdited, - dateResolved: conflictedContent!.dateModified + dateResolved: conflictedContent.dateModified }); }, [conflictedContent, selectedContent, session.content, session.note] @@ -82,8 +78,6 @@ function DiffViewer(props: DiffViewerProps) { }); }, [session]); - if (!conflictedContent || !content) return null; - return ( { @@ -110,8 +104,8 @@ function DiffViewer(props: DiffViewerProps) { }} dangerouslySetInnerHTML={{ __html: - session.type === "diff" - ? diff(session.oldContentTitle || "", session.note.title) + session.type === "diff" && session.oldTitle + ? diff(session.oldTitle || "", session.note.title) : session.note.title }} > @@ -145,28 +139,34 @@ function DiffViewer(props: DiffViewerProps) { {strings.restoreThisVersion()} - + await notesStore.refresh(); + await openSession(noteId); + }} + mr={2} + sx={{ + alignItems: "center", + justifyContent: "center", + display: "flex" + }} + > + + {strings.saveACopy()} + + )}