Files
Aislo/B06_Section/B06_Section_UI_Page_Station_Swap.ts
T
eomsangdonandClaude Opus 5.5 ec0bb044c2 feat(365-4): 한 바퀴 정리 — 저장 노선 계획고 = 횡단 한 벌 · B06 다시 그림 한 번
- 저장 노선 cross = 다시 셈 창구 한 벌(refreshCrossDesigns · 카드 · 유토곡선 · [저장] 패치가 보는 상세 설계) — 묶음 cross 가 부르고 그 설계를 냄(detailCross) · 종단도 계획고 편집 뒤 따로 예약 안 함(pipelineOwnsCross)
- B06 다시 그림 — 묶음 차례는 cross 뒤에만 · 겹친 신호(갈아끼움 · 묶음 · 초안)는 refreshDetailForStructures 한 번(최신 차례만)
- 중심점 좌우 = 노선 차례가 cross 전에 밀림 → cross 한 번(계획고 맞춤 차례 · 시험으로 못박음)
- stationDiff → logic/design_pipeline_stations(700줄)
- 시험 test_365(저장 ▲▼ 다시 셈 1 · 상세 설계 그대로 · 중심점 좌우 cross 1) · 346-2 pills · 230-2 고침

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TteK8mfYZetk5P3bEZkyVZ
2026-10-17 12:28:14 +09:00

73 lines
3.7 KiB
TypeScript

/* =============================================================================
* B06_Section_UI_Page_Station_Swap.ts
* 횡단 보기가 계산 묶음 측점을 따라감(PLAN 346-2 4파) — 가게 `stations` 가 측점 목록을 바꾸면(늘고 줄면)
* 상세 객체를 갈아끼우고(`swapSectionStations` · 조정창 값 · 암 경계 · 암 경사 옮김은 `onAnySwap` 이 맡음) 보일 때
* 카드 · 종단도를 다시(카드는 보이는 것 먼저 · 다시 셈은 그 길이 맡음 · 안 보이면 다시 보일 때 그림).
* 종단 보기도 같은 가게를 듣고 같은 함수를 부름 — 먼저 부른 쪽이 갈아끼우고 다음 쪽은 「같은 목록」.
* 노선 초안 동안(346-2 덧 3) 카드 = 묶음 새 노선 상세(`pipelineDetail` · cross 단계 결과) — 새 상세가 오면
* 같은 길로 다시 그림 · 초안을 버리면(상세 null) 저장 노선 카드로.
* 묶음 차례는 cross 뒤에만 다시 그림(profile 뒤 중간 상세는 안 그림 · 365-4) — 겹친 신호(갈아끼움 · 묶음 · 초안)는
* 횡단 보기 다시 읽기가 한 번으로 묶음(`design_view_cross` refreshDetailForStructures · 최신 차례만).
* ========================================================================== */
import { useDesignStore } from "../A00_Common/design/design_store";
import type { DesignPipeline } from "../A00_Common/design/logic/design_pipeline";
import { pagePipeline, pipelineDetail } from "../A00_Common/design/design_pipeline_page";
import type { SectionDetailResponse } from "./B06_Section_Api_Types";
import { onAnySwap, swapSectionStations } from "./B06_Section_Section_Store";
/** 카드가 그릴 상세 — 노선 초안 동안 묶음 새 노선 상세 · 아니면 저장 노선(캐시). */
export const shownDetail = (
projectId: string | null,
saved: SectionDetailResponse,
): SectionDetailResponse => (projectId && pipelineDetail(projectId)) || saved;
/** 묶음 측점을 따라감 — 돌려준 함수로 끊음. `redraw` = 캐시에서 상세를 다시 읽어 카드 · 그림 다시. */
export function followSwaps(
projectId: string | null,
routeId: () => number | null,
host: { visible: () => boolean },
redraw: () => Promise<void>,
): () => void {
if (!projectId) return () => undefined;
// 누가 갈아끼웠든(종단 보기가 먼저 불렀어도) 보이면 다시 그림 — 한 페이지 한 노선
const stopRedraw = onAnySwap(() => void (host.visible() && redraw()));
const stopStore = useDesignStore(projectId, null).subscribe("stations", (stations) => {
const route = routeId();
if (route !== null && stations?.length) void swapSectionStations(projectId, route, stations);
});
const stopDraft = followDraftDetail(projectId, () => void (host.visible() && redraw()));
return () => {
stopRedraw();
stopStore();
stopDraft();
};
}
/** 묶음 새 노선 상세가 바뀌면(cross 단계 뒤) 부름 — 묶음은 페이지가 세우므로 차례 번호가 날 때 붙음. */
function followDraftDetail(projectId: string, changed: () => void): () => void {
let pipe: DesignPipeline | null = null;
let stopPipe = (): void => undefined;
let drawn = pipelineDetail(projectId);
const attach = (): void => {
const now = pagePipeline(projectId);
if (now === pipe) return;
stopPipe();
pipe = now;
stopPipe =
now?.subscribe((event) => {
if (event.kind !== "stage" || event.stage !== "cross") return;
const next = pipelineDetail(projectId);
if (next === drawn) return;
drawn = next;
changed();
}, "횡단 카드") ?? ((): void => undefined);
};
attach();
const stopStore = useDesignStore(projectId, null).subscribe("generation", attach);
return () => {
stopStore();
stopPipe();
};
}