fix: live trades sidebar having skeletons on each tick
This commit is contained in:
parent
fc5c16e6dd
commit
ebbe067d52
1 changed files with 7 additions and 1 deletions
|
|
@ -44,6 +44,8 @@ export const isConnectedStore = writable<boolean>(false);
|
|||
export const isLoadingTrades = writable<boolean>(false);
|
||||
export const priceUpdatesStore = writable<Record<string, PriceUpdate>>({});
|
||||
|
||||
let hasLoadedInitialTrades = false;
|
||||
|
||||
// Comment callbacks
|
||||
const commentSubscriptions = new Map<string, (message: any) => void>();
|
||||
|
||||
|
|
@ -53,7 +55,9 @@ const priceUpdateSubscriptions = new Map<string, (priceUpdate: PriceUpdate) => v
|
|||
async function loadInitialTrades(): Promise<void> {
|
||||
if (!browser) return;
|
||||
|
||||
isLoadingTrades.set(true);
|
||||
if (!hasLoadedInitialTrades) {
|
||||
isLoadingTrades.set(true);
|
||||
}
|
||||
|
||||
try {
|
||||
const [largeTradesResponse, allTradesResponse] = await Promise.all([
|
||||
|
|
@ -70,6 +74,8 @@ async function loadInitialTrades(): Promise<void> {
|
|||
const { trades } = await allTradesResponse.json();
|
||||
allTradesStore.set(trades);
|
||||
}
|
||||
|
||||
hasLoadedInitialTrades = true;
|
||||
} catch (error) {
|
||||
console.error('Failed to load initial trades:', error);
|
||||
} finally {
|
||||
|
|
|
|||
Reference in a new issue