Show error when importing invalid json

This commit is contained in:
Misode
2021-08-05 00:12:30 +02:00
parent da33cc2832
commit 40fe1c5336
2 changed files with 6 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ import config from '../../config.json'
import { Analytics } from '../Analytics'
import { Ad, Btn, BtnInput, BtnMenu, ErrorPanel, HasPreview, Octicon, PreviewPanel, SourcePanel, Tree } from '../components'
import { fetchPreset } from '../DataFetcher'
import { useModel } from '../hooks'
import { locale } from '../Locales'
import type { BlockStateRegistry, VersionId } from '../Schemas'
import { checkVersion, getBlockStates, getCollections, getModel } from '../Schemas'
@@ -55,6 +56,10 @@ export function Generator({ lang, changeTitle, version, onChangeVersion }: Gener
.catch(e => { console.error(e); setError(e.message) })
}, [version, gen.id])
useModel(model, () => {
setError(null)
})
const reset = () => {
Analytics.generatorEvent('reset')
model?.reset(model.schema.default(), true)