서버 알림목록 오류 수정

This commit is contained in:
Macbook
2026-06-11 01:30:15 +09:00
parent 979c0da47a
commit 66143e5912
3 changed files with 37 additions and 14 deletions
@@ -27,16 +27,20 @@ export function normalizeStrategyId(id: unknown): number | null {
async function getStrategiesList(force = false): Promise<StrategyDto[]> {
const now = Date.now();
if (!force && strategiesCache && now - strategiesCacheAt < CACHE_MS) {
// 빈 배열은 캐시하지 않는다 — 백엔드 미준비로 빈 결과가 반환된 경우 재시도 허용
if (!force && strategiesCache && strategiesCache.length > 0 && now - strategiesCacheAt < CACHE_MS) {
return strategiesCache;
}
const list = await loadStrategies();
strategiesCache = list ?? [];
strategiesCacheAt = now;
reconcileStrategyMissingWithValidIds(
strategiesCache.map(s => s.id).filter((id): id is number => id != null && id > 0),
);
return strategiesCache;
const result = list ?? [];
if (result.length > 0) {
strategiesCache = result;
strategiesCacheAt = now;
reconcileStrategyMissingWithValidIds(
result.map(s => s.id).filter((id): id is number => id != null && id > 0),
);
}
return result;
}
function findStrategyByName(list: StrategyDto[], name: string): StrategyDto | undefined {
@@ -74,7 +78,8 @@ export async function resolveNotificationStrategy(
market?: string | null,
): Promise<ResolvedNotificationStrategy> {
const normalizedId = normalizeStrategyId(strategyId);
const list = prefetched ?? await getStrategiesList();
// prefetched가 빈 배열이면 직접 API로 재시도 (백엔드 미준비 시 prefetch가 빈 채로 캐시될 수 있음)
const list = (prefetched != null && prefetched.length > 0) ? prefetched : await getStrategiesList();
if (normalizedId != null) {
const fromList = list.find(s => s.id === normalizedId);