Fix wish import state after cancel

pull/1/head
Made Baruna 2021-12-02 23:40:03 +07:00
parent 0d89132731
commit 8245467748
No known key found for this signature in database
GPG Key ID: 5AA5DA16AA5DCEAD
1 changed files with 4 additions and 6 deletions

View File

@ -94,7 +94,10 @@
let wishes = {}; let wishes = {};
async function startImport() { async function startImport() {
cancelled = false;
error = ''; error = '';
fetchController = new AbortController();
fetchSignal = fetchController.signal;
if (selectedType === 'pclocal') { if (selectedType === 'pclocal') {
await importFromGeneratedText(); await importFromGeneratedText();
@ -121,8 +124,8 @@
await checkUID(); await checkUID();
for (const [wishNumber, type] of Object.entries(types)) { for (const [wishNumber, type] of Object.entries(types)) {
await getLog(wishNumber, type); await getLog(wishNumber, type);
if (cancelled) return;
await sleep(2000); await sleep(2000);
if (cancelled) return;
} }
if (Object.keys(wishes).length === 0) { if (Object.keys(wishes).length === 0) {
@ -514,7 +517,6 @@
if (cancelled) return; if (cancelled) return;
try { try {
console.log('trying n=', i);
const res = await fetch(url, options); const res = await fetch(url, options);
result = res; result = res;
if (res.status !== 200) { if (res.status !== 200) {
@ -524,7 +526,6 @@
return res; return res;
} catch (err) { } catch (err) {
error = err; error = err;
console.log('trying error n=', i);
} }
} }
@ -601,9 +602,6 @@
$: selectedServer, updateServer(); $: selectedServer, updateServer();
onMount(() => { onMount(() => {
fetchController = new AbortController();
fetchSignal = fetchController.signal;
detectPlatform(); detectPlatform();
selectedServer = servers.find((e) => e.value === $server); selectedServer = servers.find((e) => e.value === $server);