Skip to content

Commit 810243e

Browse files
committed
Fix potential race issue when spamming experimental toggle
1 parent aa10eb9 commit 810243e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/components/data/SoftwareDownload.svelte

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,18 @@
5454
}
5555
5656
let buildsLoading = $state(false);
57+
let buildsPromise: Promise<[] | void> = Promise.resolve([]);
5758
watch(
5859
() => version,
5960
(ver, oldVer) => {
6061
// Only handle changes, not initial page load where builds are prerendered on server.
6162
if (oldVer !== undefined && ver !== oldVer) {
62-
buildsLoading = true;
63-
fetchBuildsOrError({ value: project }, !isStable).then((result) => {
64-
builds = result;
65-
buildsLoading = false;
63+
buildsPromise = buildsPromise.then(() => {
64+
buildsLoading = true;
65+
fetchBuildsOrError({ value: project }, !isStable).then((result) => {
66+
builds = result;
67+
buildsLoading = false;
68+
});
6669
});
6770
}
6871
}

0 commit comments

Comments
 (0)