Handle doc load errors

This commit is contained in:
Misode
2024-11-21 00:48:02 +01:00
parent f3de707224
commit 4bc6e758da
2 changed files with 5 additions and 2 deletions

View File

@@ -26,6 +26,7 @@ export function ProjectPanel() {
const [entries, setEntries] = useState<string[]>()
useEffect(() => {
setEntries(undefined)
if (!service) {
return
}

View File

@@ -59,7 +59,7 @@ export function SchemaGenerator({ gen, allowedVersions }: Props) {
const [sharedSnippetId, setSharedSnippetId] = useSearchParam(SHARE_KEY)
const ignoreChange = useRef(false)
const { value: docAndNode, loading: docLoading } = useAsync(async () => {
const { value: docAndNode, loading: docLoading, error: docError } = useAsync(async () => {
let text: string | undefined = undefined
if (currentPreset && sharedSnippetId) {
setSharedSnippetId(undefined)
@@ -386,7 +386,9 @@ export function SchemaGenerator({ gen, allowedVersions }: Props) {
</BtnMenu>
</div>
{error && <ErrorPanel error={error} onDismiss={() => setError(null)} />}
<FileView docAndNode={docLoading ? undefined : docAndNode} />
{docError
? <ErrorPanel error={docError} />
: <FileView docAndNode={docLoading ? undefined : docAndNode} />}
<Footer donate={!gen.tags?.includes('partners')} />
</main>
<div class="popup-actions right-actions" style={`--offset: -${8 + actionsShown * 50}px;`}>