save-draft-fix
This commit is contained in:
parent
439be16fa1
commit
3835618f3a
|
@ -68,14 +68,13 @@ export const EditView = (props: Props) => {
|
||||||
} = useEditorContext()
|
} = useEditorContext()
|
||||||
const shoutTopics = props.shout.topics || []
|
const shoutTopics = props.shout.topics || []
|
||||||
|
|
||||||
// TODO: проверить сохранение черновика в local storage (не работает)
|
const draft = getDraftFromLocalStorage(props.shout.id)
|
||||||
const draft = props.shout || getDraftFromLocalStorage(props.shout.id)
|
let draftForm = {}
|
||||||
if (draft) {
|
if (draft) {
|
||||||
console.debug('draft from localstorage: ', draft)
|
draftForm = Object.keys(draft).length !== 0 ? draft : { shoutId: props.shout.id }
|
||||||
setForm(Object.keys(draft).length !== 0 ? draft : { shoutId: props.shout.id })
|
console.debug('draft from localstorage: ', draftForm)
|
||||||
} else {
|
} else {
|
||||||
console.debug('draft from props data: ', props.shout)
|
draftForm = {
|
||||||
setForm({
|
|
||||||
slug: props.shout.slug,
|
slug: props.shout.slug,
|
||||||
shoutId: props.shout.id,
|
shoutId: props.shout.id,
|
||||||
title: props.shout.title,
|
title: props.shout.title,
|
||||||
|
@ -88,9 +87,10 @@ export const EditView = (props: Props) => {
|
||||||
coverImageUrl: props.shout.cover,
|
coverImageUrl: props.shout.cover,
|
||||||
media: props.shout.media,
|
media: props.shout.media,
|
||||||
layout: props.shout.layout,
|
layout: props.shout.layout,
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
console.debug('draft from props data: ', draftForm)
|
||||||
|
}
|
||||||
|
setForm(draftForm)
|
||||||
const subtitleInput: { current: HTMLTextAreaElement } = { current: null }
|
const subtitleInput: { current: HTMLTextAreaElement } = { current: null }
|
||||||
|
|
||||||
const [prevForm, setPrevForm] = createStore<ShoutForm>(clone(form))
|
const [prevForm, setPrevForm] = createStore<ShoutForm>(clone(form))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user