mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -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,
|
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;
|
||||||
|
|
Loading…
Reference in a new issue