Skip to content

Commit cc05197

Browse files
authored
Add progress bar to performance page during trade history loading (#373)
1 parent b0f81aa commit cc05197

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

frontend/src/routes/performance/+page.svelte

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script lang="ts">
2+
import { untrack } from 'svelte';
23
import { accountName, sendClientMessage, serverState } from '$lib/api.svelte';
34
import PnlChart from '$lib/components/pnlChart.svelte';
45
import PriceChart from '$lib/components/priceChart.svelte';
@@ -130,7 +131,7 @@
130131
});
131132
132133
// --- Trade history loading ---
133-
let requestedMarkets = new Set<number>();
134+
let requestedMarkets = $state(new Set<number>());
134135
let prevAccountId: number | undefined = undefined;
135136
136137
// Request trade history for relevant markets
@@ -155,7 +156,7 @@
155156
156157
let delay = 0;
157158
for (const marketId of needed) {
158-
if (requestedMarkets.has(marketId)) continue;
159+
if (untrack(() => requestedMarkets.has(marketId))) continue;
159160
requestedMarkets.add(marketId);
160161
setTimeout(() => {
161162
sendClientMessage({ getFullTradeHistory: { marketId } });
@@ -358,12 +359,24 @@
358359
</script>
359360

360361
<div class="w-full pt-8">
361-
<div class="mb-6 flex items-center justify-between">
362-
<h1 class="text-xl font-bold">Performance</h1>
362+
<div class="mb-6">
363+
<div class="flex items-center justify-between">
364+
<h1 class="text-xl font-bold">Performance</h1>
365+
{#if isLoading}
366+
<span class="text-sm text-muted-foreground">
367+
Loading trade history: {loadingProgress.loaded}/{loadingProgress.total} markets...
368+
</span>
369+
{/if}
370+
</div>
363371
{#if isLoading}
364-
<span class="text-sm text-muted-foreground">
365-
Loading trade history: {loadingProgress.loaded}/{loadingProgress.total} markets...
366-
</span>
372+
<div class="mt-2 h-1.5 w-full overflow-hidden rounded-full bg-muted">
373+
<div
374+
class="h-full rounded-full bg-primary transition-all duration-300"
375+
style="width: {loadingProgress.total > 0
376+
? (loadingProgress.loaded / loadingProgress.total) * 100
377+
: 0}%"
378+
></div>
379+
</div>
367380
{/if}
368381
</div>
369382

0 commit comments

Comments
 (0)