mobile download
This commit is contained in:
@@ -432,35 +432,33 @@ export function collectDslBranches(dsl: LogicNode | null): ConditionBranch[] {
|
||||
}
|
||||
|
||||
/** DB가 1m 기본값만 갖고 편집기 localStorage에 다른 분봉이 있을 때 localStorage 우선 */
|
||||
function pickMergedStartCandleTypes(decoded: string[], stored?: string[]): string[] {
|
||||
const fromDb = normalizeCandleTypesList(decoded);
|
||||
const fromStored = stored?.length ? normalizeCandleTypesList(stored) : [];
|
||||
const dbIsLegacyDefault = fromDb.length === 1 && fromDb[0] === '1m';
|
||||
const storedDiffers = fromStored.length > 0
|
||||
&& (fromStored.length !== fromDb.length || fromStored.some((ct, i) => ct !== fromDb[i]));
|
||||
if (storedDiffers && (dbIsLegacyDefault || fromDb.length === 0)) {
|
||||
return fromStored;
|
||||
}
|
||||
return fromDb;
|
||||
}
|
||||
|
||||
/**
|
||||
* 전략 로드 시 startMeta 병합 — DB가 1m 기본값만 있고 localStorage에 다른 분봉이 있으면 localStorage 우선.
|
||||
* 전략 로드 시 startMeta 병합 — flow_layout_json(편집기)이 있으면 DSL TIMEFRAME보다 우선.
|
||||
*/
|
||||
export function mergeStartMetaForLoad(
|
||||
decoded: Record<string, StartNodeMeta>,
|
||||
stored?: Record<string, StartNodeMeta> | null,
|
||||
): Record<string, StartNodeMeta> {
|
||||
if (!stored || Object.keys(stored).length === 0) {
|
||||
const fromDsl: Record<string, StartNodeMeta> = { ...defaultStartMeta(), ...decoded };
|
||||
for (const [startId, meta] of Object.entries(decoded)) {
|
||||
const types = normalizeCandleTypesList(getStartCandleTypes(meta));
|
||||
fromDsl[startId] = { candleTypes: types, candleType: types[0] };
|
||||
}
|
||||
return fromDsl;
|
||||
}
|
||||
const merged: Record<string, StartNodeMeta> = {
|
||||
...defaultStartMeta(),
|
||||
...stored,
|
||||
};
|
||||
for (const [startId, meta] of Object.entries(decoded)) {
|
||||
const types = pickMergedStartCandleTypes(
|
||||
getStartCandleTypes(meta),
|
||||
stored?.[startId] ? getStartCandleTypes(stored[startId]) : undefined,
|
||||
);
|
||||
merged[startId] = { candleTypes: types, candleType: types[0] };
|
||||
if (stored[startId]) {
|
||||
const types = normalizeCandleTypesList(getStartCandleTypes(stored[startId]));
|
||||
merged[startId] = { candleTypes: types, candleType: types[0] };
|
||||
} else {
|
||||
const types = normalizeCandleTypesList(getStartCandleTypes(meta));
|
||||
merged[startId] = { candleTypes: types, candleType: types[0] };
|
||||
}
|
||||
}
|
||||
return merged;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user