종목목록 전일대비 정렬문제
This commit is contained in:
@@ -10,7 +10,11 @@ import { useState, useEffect, useRef, useCallback } from 'react';
|
||||
import { setMarketNames } from '../utils/marketNameCache';
|
||||
import { API_BASE } from '../utils/backendApi';
|
||||
import { UPBIT_API } from '../utils/upbitApi';
|
||||
import { fetchTickersThrottled, type UpbitTickerRaw } from '../utils/upbitTickerFetch';
|
||||
import {
|
||||
fetchTickersThrottled,
|
||||
invalidateTickerCache,
|
||||
type UpbitTickerRaw,
|
||||
} from '../utils/upbitTickerFetch';
|
||||
import { subscribeUpbitWs } from '../utils/upbitWsBroker';
|
||||
|
||||
export type ChangeDir = 'RISE' | 'FALL' | 'EVEN';
|
||||
@@ -218,6 +222,16 @@ export function useMarketTicker(opts: UseMarketTickerOptions = {}) {
|
||||
return rawList;
|
||||
}, [applyRawList, enabled]);
|
||||
|
||||
/** 전 종목 REST 재조회 (정렬·검색 패널 열림 등) — WS 우선종목과 병행 */
|
||||
const refreshAllTickers = useCallback(async (): Promise<void> => {
|
||||
if (!enabled) return;
|
||||
const all = marketListRef.current;
|
||||
if (all.length === 0) return;
|
||||
invalidateTickerCache(all);
|
||||
await loadTickersFor(all);
|
||||
if (mountedRef.current) fullLoadedRef.current = true;
|
||||
}, [enabled, loadTickersFor]);
|
||||
|
||||
const runFullTickerLoad = useCallback(async () => {
|
||||
if (!enabled) return;
|
||||
const all = marketListRef.current;
|
||||
@@ -338,5 +352,5 @@ export function useMarketTicker(opts: UseMarketTickerOptions = {}) {
|
||||
return () => clearTimeout(t);
|
||||
}, [enabled, priorityKey, loadTickersFor, attachWs, priorityList]);
|
||||
|
||||
return { tickers, marketInfos, loading, usdRate };
|
||||
return { tickers, marketInfos, loading, usdRate, refreshAllTickers };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user