mirror of
https://github.com/usememos/memos.git
synced 2024-12-18 16:41:44 +03:00
fix: clear localStorage while draft is empty (#2510)
* Clear localStorage while draft is empty * change == into ===
This commit is contained in:
parent
6814915c88
commit
6ee95a2c0c
@ -45,7 +45,8 @@ const MemoEditor = (props: Props) => {
|
||||
const { className, editorClassName, cacheKey, memoId, onConfirm } = props;
|
||||
const { i18n } = useTranslation();
|
||||
const t = useTranslate();
|
||||
const [contentCache, setContentCache] = useLocalStorage<string>(`memo-editor-${cacheKey}`, "");
|
||||
const contentCacheKey = `memo-editor-${cacheKey}`;
|
||||
const [contentCache, setContentCache] = useLocalStorage<string>(contentCacheKey, "");
|
||||
const {
|
||||
state: { systemStatus },
|
||||
} = useGlobalStore();
|
||||
@ -284,7 +285,11 @@ const MemoEditor = (props: Props) => {
|
||||
|
||||
const handleContentChange = (content: string) => {
|
||||
setHasContent(content !== "");
|
||||
if (content !== "") {
|
||||
setContentCache(content);
|
||||
} else {
|
||||
localStorage.removeItem(contentCacheKey);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSaveBtnClick = async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user