From fd7043ea4049cf42c8e2e464cfc9ebe348d7ff7a Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 5 Oct 2023 14:20:35 +0800 Subject: [PATCH] chore: fix editor cache --- web/src/components/CreateTagDialog.tsx | 9 ++++++--- web/src/components/MemoEditor/MemoEditorDialog.tsx | 2 +- web/src/components/MemoEditor/index.tsx | 5 +++-- web/src/pages/Home.tsx | 2 +- web/src/pages/MemoDetail.tsx | 1 + 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/web/src/components/CreateTagDialog.tsx b/web/src/components/CreateTagDialog.tsx index 4d380b1f..4667893a 100644 --- a/web/src/components/CreateTagDialog.tsx +++ b/web/src/components/CreateTagDialog.tsx @@ -124,9 +124,12 @@ const CreateTagDialog: React.FC = (props: Props) => { <>
{t("tag-list.tag-suggestions")} - +
{showTagSuggestions && ( <> @@ -141,7 +144,7 @@ const CreateTagDialog: React.FC = (props: Props) => { ))} - diff --git a/web/src/components/MemoEditor/MemoEditorDialog.tsx b/web/src/components/MemoEditor/MemoEditorDialog.tsx index 50bb7f07..a7ac8946 100644 --- a/web/src/components/MemoEditor/MemoEditorDialog.tsx +++ b/web/src/components/MemoEditor/MemoEditorDialog.tsx @@ -31,7 +31,7 @@ const MemoEditorDialog: React.FC = ({ memoId, relationList, destroy }: Pr
- +
); diff --git a/web/src/components/MemoEditor/index.tsx b/web/src/components/MemoEditor/index.tsx index 3b43da30..b0277042 100644 --- a/web/src/components/MemoEditor/index.tsx +++ b/web/src/components/MemoEditor/index.tsx @@ -23,6 +23,7 @@ const emptyOlReg = /^(\d+)\. $/; interface Props { className?: string; + cacheKey?: string; memoId?: MemoId; relationList?: MemoRelation[]; onConfirm?: () => void; @@ -37,10 +38,10 @@ interface State { } const MemoEditor = (props: Props) => { - const { className, memoId, onConfirm } = props; + const { className, cacheKey, memoId, onConfirm } = props; const { i18n } = useTranslation(); const t = useTranslate(); - const [contentCache, setContentCache] = useLocalStorage(`memo-editor-${props.memoId || "0"}`, ""); + const [contentCache, setContentCache] = useLocalStorage(`memo-editor-${cacheKey}`, ""); const { state: { systemStatus }, } = useGlobalStore(); diff --git a/web/src/pages/Home.tsx b/web/src/pages/Home.tsx index ccc39555..7d78d4f4 100644 --- a/web/src/pages/Home.tsx +++ b/web/src/pages/Home.tsx @@ -10,7 +10,7 @@ const Home = () => {
- +
diff --git a/web/src/pages/MemoDetail.tsx b/web/src/pages/MemoDetail.tsx index 935c40eb..647f1001 100644 --- a/web/src/pages/MemoDetail.tsx +++ b/web/src/pages/MemoDetail.tsx @@ -205,6 +205,7 @@ const MemoDetail = () => {