|
1 | 1 | <script lang="ts"> |
| 2 | + import { untrack } from 'svelte'; |
2 | 3 | import { accountName, sendClientMessage, serverState } from '$lib/api.svelte'; |
3 | 4 | import PnlChart from '$lib/components/pnlChart.svelte'; |
4 | 5 | import PriceChart from '$lib/components/priceChart.svelte'; |
|
130 | 131 | }); |
131 | 132 |
|
132 | 133 | // --- Trade history loading --- |
133 | | - let requestedMarkets = new Set<number>(); |
| 134 | + let requestedMarkets = $state(new Set<number>()); |
134 | 135 | let prevAccountId: number | undefined = undefined; |
135 | 136 |
|
136 | 137 | // Request trade history for relevant markets |
|
155 | 156 |
|
156 | 157 | let delay = 0; |
157 | 158 | for (const marketId of needed) { |
158 | | - if (requestedMarkets.has(marketId)) continue; |
| 159 | + if (untrack(() => requestedMarkets.has(marketId))) continue; |
159 | 160 | requestedMarkets.add(marketId); |
160 | 161 | setTimeout(() => { |
161 | 162 | sendClientMessage({ getFullTradeHistory: { marketId } }); |
|
358 | 359 | </script> |
359 | 360 |
|
360 | 361 | <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> |
363 | 371 | {#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> |
367 | 380 | {/if} |
368 | 381 | </div> |
369 | 382 |
|
|
0 commit comments