config upload fix
This commit is contained in:
@@ -50,13 +50,25 @@
|
||||
});
|
||||
|
||||
async function load(): Promise<void> {
|
||||
const [pluginRes, scopeRes] = await Promise.all([
|
||||
fetch('/api/plugins'),
|
||||
fetch('/api/scope-options')
|
||||
]);
|
||||
plugins = (await pluginRes.json()).scripts;
|
||||
scopeOptions = (await scopeRes.json()) as ScopeOptions;
|
||||
loading = false;
|
||||
try {
|
||||
const [pluginRes, scopeRes] = await Promise.all([
|
||||
fetch('/api/plugins'),
|
||||
fetch('/api/scope-options')
|
||||
]);
|
||||
if (!pluginRes.ok) {
|
||||
flash = `plugins API returned ${pluginRes.status}. If this is a dev environment, restart the server so the DB migration runs.`;
|
||||
plugins = [];
|
||||
} else {
|
||||
plugins = ((await pluginRes.json()) as { scripts?: ArtifactRow[] }).scripts ?? [];
|
||||
}
|
||||
if (scopeRes.ok) {
|
||||
scopeOptions = ((await scopeRes.json()) as ScopeOptions | undefined) ?? { games: [], mapsByGame: {} };
|
||||
}
|
||||
} catch (err) {
|
||||
flash = `failed to load plugins: ${(err as Error).message}`;
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMount(load);
|
||||
|
||||
Reference in New Issue
Block a user