mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
fix: cancel removes memo cache (#3826)
Clear local storage record of memo changes if chanes to a memo are cancelled
This commit is contained in:
@@ -53,7 +53,7 @@ interface State {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const MemoEditor = (props: Props) => {
|
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 t = useTranslate();
|
||||||
const { i18n } = useTranslation();
|
const { i18n } = useTranslation();
|
||||||
const workspaceSettingStore = useWorkspaceSettingStore();
|
const workspaceSettingStore = useWorkspaceSettingStore();
|
||||||
@@ -364,6 +364,14 @@ const MemoEditor = (props: Props) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCancelBtnClick = () => {
|
||||||
|
localStorage.removeItem(contentCacheKey);
|
||||||
|
|
||||||
|
if (onCancel) {
|
||||||
|
onCancel();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleEditorFocus = () => {
|
const handleEditorFocus = () => {
|
||||||
editorRef.current?.focus();
|
editorRef.current?.focus();
|
||||||
};
|
};
|
||||||
@@ -457,7 +465,7 @@ const MemoEditor = (props: Props) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="shrink-0 flex flex-row justify-end items-center gap-2">
|
<div className="shrink-0 flex flex-row justify-end items-center gap-2">
|
||||||
{props.onCancel && (
|
{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")}
|
{t("common.cancel")}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
Reference in New Issue
Block a user