From 82454677484075cc5607c3c33e2b5bdec42ddbb1 Mon Sep 17 00:00:00 2001 From: Made Baruna Date: Thu, 2 Dec 2021 23:40:03 +0700 Subject: [PATCH] Fix wish import state after cancel --- src/routes/wish/import.svelte | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/routes/wish/import.svelte b/src/routes/wish/import.svelte index 3e4d6a12..34698b12 100644 --- a/src/routes/wish/import.svelte +++ b/src/routes/wish/import.svelte @@ -94,7 +94,10 @@ let wishes = {}; async function startImport() { + cancelled = false; error = ''; + fetchController = new AbortController(); + fetchSignal = fetchController.signal; if (selectedType === 'pclocal') { await importFromGeneratedText(); @@ -121,8 +124,8 @@ await checkUID(); for (const [wishNumber, type] of Object.entries(types)) { await getLog(wishNumber, type); - if (cancelled) return; await sleep(2000); + if (cancelled) return; } if (Object.keys(wishes).length === 0) { @@ -514,7 +517,6 @@ if (cancelled) return; try { - console.log('trying n=', i); const res = await fetch(url, options); result = res; if (res.status !== 200) { @@ -524,7 +526,6 @@ return res; } catch (err) { error = err; - console.log('trying error n=', i); } } @@ -601,9 +602,6 @@ $: selectedServer, updateServer(); onMount(() => { - fetchController = new AbortController(); - fetchSignal = fetchController.signal; - detectPlatform(); selectedServer = servers.find((e) => e.value === $server);