mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
Close import log page on error (#2639)
This commit is contained in:
parent
c45f3cb0af
commit
8e5bd2c3a1
1 changed files with 23 additions and 12 deletions
|
@ -10,6 +10,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
importJsonFile,
|
||||
importJsonString,
|
||||
} from "@tslib/backend";
|
||||
import { bridgeCommand } from "@tslib/bridgecommand";
|
||||
import * as tr from "@tslib/ftl";
|
||||
|
||||
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;
|
||||
|
||||
async function onImport(): Promise<ImportResponse | undefined> {
|
||||
const postOptions = { alertOnError: false };
|
||||
let result: ImportResponse | undefined;
|
||||
switch (params.type) {
|
||||
case "apkg":
|
||||
result = await importAnkiPackage({
|
||||
packagePath: params.path,
|
||||
});
|
||||
break;
|
||||
case "json_file":
|
||||
result = await importJsonFile({ val: params.path });
|
||||
break;
|
||||
case "json_string":
|
||||
result = await importJsonString({ val: params.json });
|
||||
break;
|
||||
try {
|
||||
switch (params.type) {
|
||||
case "apkg":
|
||||
result = await importAnkiPackage(
|
||||
{
|
||||
packagePath: params.path,
|
||||
},
|
||||
postOptions,
|
||||
);
|
||||
break;
|
||||
case "json_file":
|
||||
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({});
|
||||
return result;
|
||||
|
|
Loading…
Reference in a new issue