Skip to content

Commit f9d2c37

Browse files
committed
chore: Refactor MarkdownEditorContainer.tsx for improved temp save functionality
1 parent 5e02e2b commit f9d2c37

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/containers/write/MarkdownEditorContainer.tsx

+11-11
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ const MarkdownEditorContainer: React.FC<MarkdownEditorContainerProps> = () => {
279279
dispatch(setWritePostId(id));
280280
history.replace(`/write?id=${id}`);
281281
}
282-
282+
283283
if (!id) return;
284284

285285
const url = URL.createObjectURL(file);
@@ -306,16 +306,16 @@ const MarkdownEditorContainer: React.FC<MarkdownEditorContainerProps> = () => {
306306

307307
useEffect(() => {
308308
const changed = !shallowEqual(lastSavedData, { title, body: markdown });
309-
if (!changed) return;
310-
311-
const timeoutId = setTimeout(() => {
312-
if (!postId && !title && markdown.length < 30) return;
313-
onTempSave(false);
314-
}, 1000 * 10);
315-
316-
return () => {
317-
clearTimeout(timeoutId);
318-
};
309+
if (changed) {
310+
const timeoutId = setTimeout(() => {
311+
if (!postId && !title && markdown.length < 30) return;
312+
onTempSave(true);
313+
}, 10 * 1000);
314+
315+
return () => {
316+
clearTimeout(timeoutId);
317+
};
318+
}
319319
}, [title, postId, onTempSave, lastSavedData, markdown]);
320320

321321
useSaveHotKey(() => onTempSave(true));

0 commit comments

Comments
 (0)