알림 시간봉 오류 수정

This commit is contained in:
Macbook
2026-05-29 20:42:35 +09:00
parent a5f0a7eefd
commit 775f83e1b3
13 changed files with 200 additions and 35 deletions
+20 -3
View File
@@ -155,7 +155,9 @@ export function updateStartCandleTypes(
candleTypes: string[],
): EditorConditionState {
const types = normalizeCandleTypesList(candleTypes);
const primary = types[0];
// 조건 노드 left/rightCandleType 동기화는 "대표 분봉"에만 사용되므로,
// multi 분봉에서 stale 1m 이 앞에 오는 경우 1m 로 동기화되지 않도록 non-1m 을 우선한다.
const primary = types.find(ct => normalizeStartCandleType(ct) !== '1m') ?? types[0];
const nextMeta = {
...state.startMeta,
[startId]: { candleTypes: types, candleType: primary },
@@ -197,7 +199,13 @@ function normalizeCandleTypesList(types: string[]): string[] {
out.push(ct);
}
}
return out.length > 0 ? out : [DEFAULT_START_CANDLE];
if (out.length === 0) return [DEFAULT_START_CANDLE];
// 레거시/불일치로 multi 분봉에 stale 1m 이 섞인 경우가 있어,
// multi 인데 non-1m 이 있으면 1m 을 기본적으로 제외한다.
if (out.length > 1 && out.includes('1m') && out.some(ct => ct !== '1m')) {
return out.filter(ct => ct !== '1m');
}
return out;
}
function readTimeframeCandleTypes(node: LogicNode): string[] {
@@ -467,7 +475,16 @@ export function mergeStartMetaForLoad(
};
for (const [startId, meta] of Object.entries(decoded)) {
if (stored[startId]) {
const types = normalizeCandleTypesList(getStartCandleTypes(stored[startId]));
const storedTypes = normalizeCandleTypesList(getStartCandleTypes(stored[startId]));
const decodedTypes = normalizeCandleTypesList(getStartCandleTypes(meta));
// flow_layout_json 에 stale 1m 이 남아 있는 경우가 있어,
// DSL 에 1m 이 없고 non-1m 이 있으면 DSL 쪽을 우선한다.
const shouldPreferDecoded =
storedTypes.includes('1m')
&& storedTypes.some(ct => ct !== '1m')
&& !decodedTypes.includes('1m')
&& decodedTypes.some(ct => ct !== '1m');
const types = shouldPreferDecoded ? decodedTypes : storedTypes;
merged[startId] = { candleTypes: types, candleType: types[0] };
} else {
const types = normalizeCandleTypesList(getStartCandleTypes(meta));
@@ -0,0 +1,38 @@
/**
* STOMP·실시간 시그널 소유자 검증 — 로그인 사용자는 user_id, 비로그인은 device_id 기준.
*/
export interface SignalOwnership {
userId?: number | null;
deviceId?: string | null;
}
function readDeviceId(): string {
return localStorage.getItem('gc_device_id') ?? '';
}
function readUserId(): number | null {
const raw = localStorage.getItem('gc_user_id');
if (!raw) return null;
const id = Number(raw);
return Number.isFinite(id) && id > 0 ? id : null;
}
export function getCurrentSignalSession(): { userId: number | null; deviceId: string } {
return { userId: readUserId(), deviceId: readDeviceId() };
}
/** STOMP 페이로드·DB 시그널이 현재 세션 소유인지 */
export function signalBelongsToCurrentSession(owner: SignalOwnership): boolean {
const { userId, deviceId } = getCurrentSignalSession();
if (owner.userId != null && owner.userId > 0) {
return userId != null && userId === owner.userId;
}
if (owner.deviceId != null && owner.deviceId !== '') {
return userId == null && owner.deviceId === deviceId;
}
// 소유자 메타 없음(레거시 브로드캐스트) — 타 사용자 시그널 유입 방지
return false;
}