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