From 1d5b18918519fef4c75f58cc2ea06592b292df55 Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Sun, 23 Feb 2025 15:32:57 +0100 Subject: [PATCH] fix: preserve note id when changing style and preserve style when changing color, closes #252 (#436) --- .../src/app/reader/components/annotator/Annotator.tsx | 1 + .../src/app/reader/components/annotator/HighlightOptions.tsx | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/readest-app/src/app/reader/components/annotator/Annotator.tsx b/apps/readest-app/src/app/reader/components/annotator/Annotator.tsx index 58d738fd..62231223 100644 --- a/apps/readest-app/src/app/reader/components/annotator/Annotator.tsx +++ b/apps/readest-app/src/app/reader/components/annotator/Annotator.tsx @@ -357,6 +357,7 @@ const Annotator: React.FC<{ bookKey: string }> = ({ bookKey }) => { if (existingIndex !== -1) { views.forEach((view) => view?.addAnnotation(annotation, true)); if (update) { + annotation.id = annotations[existingIndex]!.id; annotations[existingIndex] = annotation; views.forEach((view) => view?.addAnnotation(annotation)); } else { diff --git a/apps/readest-app/src/app/reader/components/annotator/HighlightOptions.tsx b/apps/readest-app/src/app/reader/components/annotator/HighlightOptions.tsx index c3a207e0..8fc51e49 100644 --- a/apps/readest-app/src/app/reader/components/annotator/HighlightOptions.tsx +++ b/apps/readest-app/src/app/reader/components/annotator/HighlightOptions.tsx @@ -37,8 +37,8 @@ const HighlightOptions: React.FC = ({ onHandleHighlight(true); }; const handleSelectColor = (color: HighlightColor) => { - const style = globalReadSettings.highlightStyle; - globalReadSettings.highlightStyles[style] = color; + globalReadSettings.highlightStyle = selectedStyle; + globalReadSettings.highlightStyles[selectedStyle] = color; setSettings(settings); setSelectedColor(color); onHandleHighlight(true);