Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: cancel removes memo cache (#3826)

RoccoSmiteca9649be3c4
diff --git a/web/src/components/MemoEditor/index.tsx b/web/src/components/MemoEditor/index.tsx
index 6b54a736f..a3f3086de 100644
--- a/web/src/components/MemoEditor/index.tsx
+++ b/web/src/components/MemoEditor/index.tsx
@@ -53,7 +53,7 @@ interface State {
}
const MemoEditor = (props: Props) => {
- const { className, cacheKey, memoName, parentMemoName, autoFocus, onConfirm } = props;
+ const { className, cacheKey, memoName, parentMemoName, autoFocus, onConfirm, onCancel } = props;
const t = useTranslate();
const { i18n } = useTranslation();
const workspaceSettingStore = useWorkspaceSettingStore();
@@ -364,6 +364,14 @@ const MemoEditor = (props: Props) => {
});
};
+ const handleCancelBtnClick = () => {
+ localStorage.removeItem(contentCacheKey);
+
+ if (onCancel) {
+ onCancel();
+ }
+ };
+
const handleEditorFocus = () => {
editorRef.current?.focus();
};
@@ -457,7 +465,7 @@ const MemoEditor = (props: Props) => {
</div>
<div className="shrink-0 flex flex-row justify-end items-center gap-2">
{props.onCancel && (
- <Button className="!font-normal" color="neutral" variant="plain" loading={state.isRequesting} onClick={props.onCancel}>
+ <Button className="!font-normal" color="neutral" variant="plain" loading={state.isRequesting} onClick={handleCancelBtnClick}>
{t("common.cancel")}
</Button>
)}