Skip to content

Commit

Permalink
Fix race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
nortonandreev committed Aug 15, 2024
1 parent 7a5714e commit 44d237d
Showing 1 changed file with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,31 @@
/** @type {boolean} */
export let isValid = false;
// A race condition here – needs fixing
$: isValid = !sync.inProgress;
let syncStarted = false;
$: if (!syncStarted && sync.inProgress) {
syncStarted = true;
}
$: isValid = syncStarted && !sync.inProgress;
onDestroy(() => {
logout(false);
});
</script>

<IconHeadingCard iconPath={mdiCubeOutline} heading="Please wait...">
{#if sync.inProgress}
{#if !sync.current || !sync.latest}
<span>Syncing</span>
{:else}
<span>
Syncing: <b
>{sync.current.toLocaleString()}/{sync.latest.toLocaleString()}</b
>
</span>
<ProgressBar
className="footer__sync-status-progress-bar"
currentPercentage={(sync.current / sync.latest) * 100}
/>
{/if}
<IconHeadingCard iconPath={mdiCubeOutline} heading="Network Sync">
{#if !syncStarted || (sync.inProgress && (!sync.current || !sync.latest))}
<span>Syncing...</span>
{:else if sync.inProgress}
<span>
Syncing: <b
>{sync.current.toLocaleString()}/{sync.latest.toLocaleString()}</b
>
</span>
<ProgressBar
className="footer__sync-status-progress-bar"
currentPercentage={(sync.current / sync.latest) * 100}
/>
{:else}
<span>Sync completed!</span>
{/if}
Expand Down

0 comments on commit 44d237d

Please sign in to comment.