/* ============================================================================= * B06_Section_UI_Page_Station_Swap.ts * 횡단 보기가 계산 묶음 측점을 따라감(PLAN 346-2 4파) — 가게 `stations` 가 측점 목록을 바꾸면(늘고 줄면) * 상세 객체를 갈아끼우고(`swapSectionStations`) 조정창 값 · 암 경계 · 암 경사를 새 자리로 옮긴 뒤 보일 때 카드 · * 종단도를 다시(카드는 보이는 것 먼저 · 다시 셈은 그 길이 맡음 · 안 보이면 다시 보일 때 그림). * ========================================================================== */ import { useDesignStore } from "../A00_Common/design/design_store"; import { swapSectionStations } from "./B06_Section_Section_Store"; import { moveSessionMaps } from "./B06_Section_UI_Page_Link_Session"; import { reloadKeyedStores } from "./B06_Section_UI_Page_Persist"; /** 묶음 측점을 따라감 — 돌려준 함수로 끊음. `redraw` = 캐시에서 상세를 다시 읽어 카드 · 그림 다시. */ export function followSwaps( projectId: string | null, routeId: () => number | null, host: { visible: () => boolean }, redraw: () => Promise, ): () => void { if (!projectId) return () => undefined; return useDesignStore(projectId, null).subscribe("stations", (stations) => { const route = routeId(); if (route === null || !stations?.length) return; void swapSectionStations(projectId, route, stations).then((swap) => { if (!swap) return; // 같은 목록 — 제자리 갱신 길이 맡음 moveSessionMaps(swap.moves); // 조정창 값(반폭 · 기슭막이 · 유입 · 집수정 · 추가 벽) reloadKeyedStores(); // 암 경계 · 암 경사 = 측점 열쇠 세션 → 새 목록 누가거리로 if (host.visible()) void redraw(); }); }); }