parse-tolerate
This commit is contained in:
parent
6fa6076f9f
commit
002ffe64fc
|
@ -135,7 +135,7 @@ export const FullArticle = (props: Props) => {
|
|||
|
||||
const media = createMemo<MediaItem[]>(() => {
|
||||
try {
|
||||
return JSON.parse(props.article.media)
|
||||
return JSON.parse(props.article?.media || "[]")
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ export const ConnectProvider = (props: { children: JSX.Element }) => {
|
|||
Authorization: token,
|
||||
},
|
||||
onmessage(event) {
|
||||
const m: SSEMessage = JSON.parse(event.data)
|
||||
const m: SSEMessage = JSON.parse(event.data || "{}")
|
||||
console.log('[context.connect] Received message:', m)
|
||||
|
||||
// Iterate over all registered handlers and call them
|
||||
|
|
|
@ -72,7 +72,7 @@ const saveDraftToLocalStorage = (formToSave: ShoutForm) => {
|
|||
localStorage.setItem(`shout-${formToSave.shoutId}`, JSON.stringify(formToSave))
|
||||
}
|
||||
const getDraftFromLocalStorage = (shoutId: number) => {
|
||||
return JSON.parse(localStorage.getItem(`shout-${shoutId}`) || '')
|
||||
return JSON.parse(localStorage.getItem(`shout-${shoutId}`) || '{}')
|
||||
}
|
||||
|
||||
const removeDraftFromLocalStorage = (shoutId: number) => {
|
||||
|
@ -105,7 +105,7 @@ export const EditorProvider = (props: { children: JSX.Element }) => {
|
|||
return false
|
||||
}
|
||||
|
||||
const parsedMedia = JSON.parse(form.media || '')
|
||||
const parsedMedia = JSON.parse(form.media || '[]')
|
||||
if (form.layout === 'video' && !parsedMedia[0]) {
|
||||
snackbar?.showSnackbar({
|
||||
type: 'error',
|
||||
|
|
Loading…
Reference in New Issue
Block a user