diff --git a/ts/lib/tslib/progress.ts b/ts/lib/tslib/progress.ts index 86381b264..cbf13e601 100644 --- a/ts/lib/tslib/progress.ts +++ b/ts/lib/tslib/progress.ts @@ -8,13 +8,19 @@ export async function runWithBackendProgress( callback: () => Promise, onUpdate: (progress: Progress) => void, ): Promise { - const intervalId = setInterval(async () => { + let done = false; + async function progressCallback() { const progress = await latestProgress({}); onUpdate(progress); - }, 100); + if (done) { + return; + } + setTimeout(progressCallback, 100); + } + setTimeout(progressCallback, 100); try { return await callback(); } finally { - clearInterval(intervalId); + done = true; } } diff --git a/ts/routes/deck-options/FsrsOptions.svelte b/ts/routes/deck-options/FsrsOptions.svelte index 905f41c13..9c91d02e4 100644 --- a/ts/routes/deck-options/FsrsOptions.svelte +++ b/ts/routes/deck-options/FsrsOptions.svelte @@ -150,7 +150,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html )) || resp.weights.length === 0 ) { - alert(tr.deckConfigFsrsParamsOptimal()); + setTimeout(() => alert(tr.deckConfigFsrsParamsOptimal()), 100); } if (computeWeightsProgress) { computeWeightsProgress.current = computeWeightsProgress.total;