diff --git a/src/components/Views/EditView/EditView.tsx b/src/components/Views/EditView/EditView.tsx index 1969e338..3ef489ca 100644 --- a/src/components/Views/EditView/EditView.tsx +++ b/src/components/Views/EditView/EditView.tsx @@ -64,10 +64,11 @@ export const EditView = (props: Props) => { getDraftFromLocalStorage, } = useEditorContext() const shoutTopics = props.shout.topics || [] - const draft = getDraftFromLocalStorage(props.shout.id) + // TODO: проверить сохранение черновика в local storage (не работает) + const draft = getDraftFromLocalStorage(props.shout.id) if (draft) { - setForm(draft) + setForm(Object.keys(draft).length !== 0 ? draft : { shoutId: props.shout.id }); } else { setForm({ slug: props.shout.slug, @@ -179,6 +180,7 @@ export const EditView = (props: Props) => { let autoSaveTimeOutId: number | string | NodeJS.Timeout + //TODO: add throttle const autoSaveRecursive = () => { autoSaveTimeOutId = setTimeout(async () => { const hasChanges = !deepEqual(form, prevForm) diff --git a/src/context/editor.tsx b/src/context/editor.tsx index da9fe026..5369df88 100644 --- a/src/context/editor.tsx +++ b/src/context/editor.tsx @@ -184,8 +184,10 @@ export const EditorProvider = (props: { children: JSX.Element }) => { } const saveDraft = async (draftForm: ShoutForm) => { + console.log("!!! draftForm:", draftForm); const { error } = await updateShout(draftForm, { publish: false }) if (error) { + console.log("!!! error:", error); snackbar?.showSnackbar({ type: 'error', body: localize?.t(error) || '' }) return }