Close import log page on error (#2639)

This commit is contained in:
Abdo 2023-09-05 03:47:49 +03:00 committed by GitHub
parent c45f3cb0af
commit 8e5bd2c3a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,6 +10,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
importJsonFile, importJsonFile,
importJsonString, importJsonString,
} from "@tslib/backend"; } from "@tslib/backend";
import { bridgeCommand } from "@tslib/bridgecommand";
import * as tr from "@tslib/ftl"; import * as tr from "@tslib/ftl";
import BackendProgressIndicator from "../components/BackendProgressIndicator.svelte"; import BackendProgressIndicator from "../components/BackendProgressIndicator.svelte";
@ -28,19 +29,29 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
let closeButton: HTMLElement; let closeButton: HTMLElement;
async function onImport(): Promise<ImportResponse | undefined> { async function onImport(): Promise<ImportResponse | undefined> {
const postOptions = { alertOnError: false };
let result: ImportResponse | undefined; let result: ImportResponse | undefined;
switch (params.type) { try {
case "apkg": switch (params.type) {
result = await importAnkiPackage({ case "apkg":
packagePath: params.path, result = await importAnkiPackage(
}); {
break; packagePath: params.path,
case "json_file": },
result = await importJsonFile({ val: params.path }); postOptions,
break; );
case "json_string": break;
result = await importJsonString({ val: params.json }); case "json_file":
break; result = await importJsonFile({ val: params.path }, postOptions);
break;
case "json_string":
result = await importJsonString({ val: params.json }, postOptions);
break;
}
} catch (err) {
alert(err);
bridgeCommand("close");
throw err;
} }
await importDone({}); await importDone({});
return result; return result;