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 isLoadingTrades = writable<boolean>(false);
|
||||||
export const priceUpdatesStore = writable<Record<string, PriceUpdate>>({});
|
export const priceUpdatesStore = writable<Record<string, PriceUpdate>>({});
|
||||||
|
|
||||||
|
let hasLoadedInitialTrades = false;
|
||||||
|
|
||||||
// Comment callbacks
|
// Comment callbacks
|
||||||
const commentSubscriptions = new Map<string, (message: any) => void>();
|
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> {
|
async function loadInitialTrades(): Promise<void> {
|
||||||
if (!browser) return;
|
if (!browser) return;
|
||||||
|
|
||||||
|
if (!hasLoadedInitialTrades) {
|
||||||
isLoadingTrades.set(true);
|
isLoadingTrades.set(true);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const [largeTradesResponse, allTradesResponse] = await Promise.all([
|
const [largeTradesResponse, allTradesResponse] = await Promise.all([
|
||||||
|
|
@ -70,6 +74,8 @@ async function loadInitialTrades(): Promise<void> {
|
||||||
const { trades } = await allTradesResponse.json();
|
const { trades } = await allTradesResponse.json();
|
||||||
allTradesStore.set(trades);
|
allTradesStore.set(trades);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasLoadedInitialTrades = true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to load initial trades:', error);
|
console.error('Failed to load initial trades:', error);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
||||||
Reference in a new issue