new-draft-store-fix
This commit is contained in:
parent
c959a2bba4
commit
7288725480
|
@ -73,7 +73,7 @@ export const EditView = (props: Props) => {
|
||||||
const [isLeadVisible, setIsLeadVisible] = createSignal(Boolean(form.lead))
|
const [isLeadVisible, setIsLeadVisible] = createSignal(Boolean(form.lead))
|
||||||
const [isScrolled, setIsScrolled] = createSignal(false)
|
const [isScrolled, setIsScrolled] = createSignal(false)
|
||||||
const [shoutTopics, setShoutTopics] = createSignal<Topic[]>([])
|
const [shoutTopics, setShoutTopics] = createSignal<Topic[]>([])
|
||||||
const [draft, setDraft] = createSignal<Shout>()
|
const [draft, setDraft] = createSignal<Shout>(props.shout)
|
||||||
const [mediaItems, setMediaItems] = createSignal<MediaItem[]>([])
|
const [mediaItems, setMediaItems] = createSignal<MediaItem[]>([])
|
||||||
|
|
||||||
const client = createMemo(() => graphqlClientCreate(coreApiUrl, session()?.access_token))
|
const client = createMemo(() => graphqlClientCreate(coreApiUrl, session()?.access_token))
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { Button } from '~/components/_shared/Button'
|
||||||
import { Icon } from '~/components/_shared/Icon'
|
import { Icon } from '~/components/_shared/Icon'
|
||||||
import { PageLayout } from '~/components/_shared/PageLayout'
|
import { PageLayout } from '~/components/_shared/PageLayout'
|
||||||
import { coreApiUrl } from '~/config'
|
import { coreApiUrl } from '~/config'
|
||||||
|
import { useEditorContext } from '~/context/editor'
|
||||||
import { useLocalize } from '~/context/localize'
|
import { useLocalize } from '~/context/localize'
|
||||||
import { useSession } from '~/context/session'
|
import { useSession } from '~/context/session'
|
||||||
import { useSnackbar } from '~/context/ui'
|
import { useSnackbar } from '~/context/ui'
|
||||||
|
@ -17,6 +18,7 @@ import { LayoutType } from '~/types/common'
|
||||||
export default () => {
|
export default () => {
|
||||||
const { t } = useLocalize()
|
const { t } = useLocalize()
|
||||||
const { session } = useSession()
|
const { session } = useSession()
|
||||||
|
const { saveDraftToLocalStorage } = useEditorContext()
|
||||||
const client = createMemo(() => graphqlClientCreate(coreApiUrl, session()?.access_token))
|
const client = createMemo(() => graphqlClientCreate(coreApiUrl, session()?.access_token))
|
||||||
|
|
||||||
const { showSnackbar } = useSnackbar()
|
const { showSnackbar } = useSnackbar()
|
||||||
|
@ -29,12 +31,23 @@ export default () => {
|
||||||
if (result) {
|
if (result) {
|
||||||
console.debug(result)
|
console.debug(result)
|
||||||
const { shout, error } = result.data.create_shout
|
const { shout, error } = result.data.create_shout
|
||||||
if (error)
|
if (error) {
|
||||||
showSnackbar({
|
showSnackbar({
|
||||||
body: `${t('Error')}: ${t(error)}`,
|
body: `${t('Error')}: ${t(error)}`,
|
||||||
type: 'error'
|
type: 'error'
|
||||||
})
|
})
|
||||||
if (shout?.id) navigate(`/edit/${shout.id}`)
|
return
|
||||||
|
}
|
||||||
|
if (shout?.id) {
|
||||||
|
saveDraftToLocalStorage({
|
||||||
|
shoutId: shout.id,
|
||||||
|
selectedTopics: shout.topics,
|
||||||
|
slug: shout.slug,
|
||||||
|
title: '',
|
||||||
|
body: ''
|
||||||
|
})
|
||||||
|
navigate(`/edit/${shout.id}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user