서버 알림목록 로딩 오류 수정
This commit is contained in:
@@ -16,7 +16,10 @@ import {
|
|||||||
type VirtualIndicatorSnapshot,
|
type VirtualIndicatorSnapshot,
|
||||||
} from './useVirtualIndicatorSnapshots';
|
} from './useVirtualIndicatorSnapshots';
|
||||||
|
|
||||||
const MAX_EMPTY_RETRIES = 15;
|
/** 전략을 찾았지만 백엔드가 아직 조건을 평가하지 않은 경우 — warm-up 대기 (10분) */
|
||||||
|
const MAX_EMPTY_RETRIES_WARM = 200;
|
||||||
|
/** 전략 자체를 찾지 못한 경우 — 빠르게 "데이터 없음" 표시 */
|
||||||
|
const MAX_EMPTY_RETRIES_NO_STRATEGY = 3;
|
||||||
|
|
||||||
function staticFallback(
|
function staticFallback(
|
||||||
market: string,
|
market: string,
|
||||||
@@ -48,6 +51,7 @@ export function useTradeNotificationSignalSnapshot(
|
|||||||
const [snapshot, setSnapshot] = useState<VirtualIndicatorSnapshot | undefined>();
|
const [snapshot, setSnapshot] = useState<VirtualIndicatorSnapshot | undefined>();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const emptyRetryRef = useRef(0);
|
const emptyRetryRef = useRef(0);
|
||||||
|
const strategyResolvedRef = useRef(false);
|
||||||
const genRef = useRef(0);
|
const genRef = useRef(0);
|
||||||
const refreshInFlightRef = useRef(false);
|
const refreshInFlightRef = useRef(false);
|
||||||
const resolvedStrategyRef = useRef<StrategyDto | undefined>();
|
const resolvedStrategyRef = useRef<StrategyDto | undefined>();
|
||||||
@@ -93,6 +97,7 @@ export function useTradeNotificationSignalSnapshot(
|
|||||||
if (resolved.strategy) {
|
if (resolved.strategy) {
|
||||||
effectiveStrategy = resolved.strategy;
|
effectiveStrategy = resolved.strategy;
|
||||||
resolvedStrategyRef.current = resolved.strategy;
|
resolvedStrategyRef.current = resolved.strategy;
|
||||||
|
strategyResolvedRef.current = true;
|
||||||
}
|
}
|
||||||
if (resolved.strategyId != null) {
|
if (resolved.strategyId != null) {
|
||||||
effectiveId = resolved.strategyId;
|
effectiveId = resolved.strategyId;
|
||||||
@@ -100,6 +105,9 @@ export function useTradeNotificationSignalSnapshot(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 전략을 prop 또는 resolution으로 확보했으면 resolved 표시
|
||||||
|
if (effectiveStrategy) strategyResolvedRef.current = true;
|
||||||
|
|
||||||
const pinFirst = emptyRetryRef.current === 0;
|
const pinFirst = emptyRetryRef.current === 0;
|
||||||
let snap = await fetchLiveSnapshot(
|
let snap = await fetchLiveSnapshot(
|
||||||
normalizedMarket,
|
normalizedMarket,
|
||||||
@@ -122,9 +130,13 @@ export function useTradeNotificationSignalSnapshot(
|
|||||||
|
|
||||||
if (gen === genRef.current) {
|
if (gen === genRef.current) {
|
||||||
setSnapshot(snap ?? undefined);
|
setSnapshot(snap ?? undefined);
|
||||||
const stillCollecting = (!snap || snap.rows.length === 0)
|
const isEmpty = !snap || snap.rows.length === 0;
|
||||||
&& emptyRetryRef.current < MAX_EMPTY_RETRIES;
|
// 전략이 확인된 경우: 백엔드 warm-up을 충분히 기다림 (10분)
|
||||||
setLoading(stillCollecting);
|
// 전략 자체를 찾지 못한 경우: 빠르게 "데이터 없음" 표시
|
||||||
|
const maxRetries = strategyResolvedRef.current
|
||||||
|
? MAX_EMPTY_RETRIES_WARM
|
||||||
|
: MAX_EMPTY_RETRIES_NO_STRATEGY;
|
||||||
|
setLoading(isEmpty && emptyRetryRef.current < maxRetries);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
refreshInFlightRef.current = false;
|
refreshInFlightRef.current = false;
|
||||||
@@ -145,11 +157,13 @@ export function useTradeNotificationSignalSnapshot(
|
|||||||
setSnapshot(undefined);
|
setSnapshot(undefined);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
emptyRetryRef.current = 0;
|
emptyRetryRef.current = 0;
|
||||||
|
strategyResolvedRef.current = false;
|
||||||
resolvedStrategyRef.current = undefined;
|
resolvedStrategyRef.current = undefined;
|
||||||
effectiveStrategyIdRef.current = null;
|
effectiveStrategyIdRef.current = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
emptyRetryRef.current = 0;
|
emptyRetryRef.current = 0;
|
||||||
|
strategyResolvedRef.current = strategy != null;
|
||||||
resolvedStrategyRef.current = strategy ? hydrateStrategyDto(strategy) : undefined;
|
resolvedStrategyRef.current = strategy ? hydrateStrategyDto(strategy) : undefined;
|
||||||
effectiveStrategyIdRef.current = strategy?.id ?? rawId;
|
effectiveStrategyIdRef.current = strategy?.id ?? rawId;
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user