Files
Aislo/B05_Profile/B05_Profile_Api_Pipes_Draft.ts
eomsangdonandClaude Opus 5 165b281fe1 fix(B05,B06): 배수관 편집을 세션 초안에 쌓아 B06 저장에도 실리게 함
관 추가·이동·삭제가 B05 패널 메모리에만 있어, B06 으로 넘어가 [저장]·[확정]하면 그
편집이 사라졌음(대응표 조사에서 드러남).

- 등록표에 `pipes` 초안(프로젝트 범위)을 되살림
- 배치가 바뀌는 순간 목록을 초안에 담고, 내보내기는 `flushPendingPipes` 한 창구로 모음
- B05 [임시저장]·B06 [저장]·[확정] 모두 이 창구를 지남 (자동저장 없음)

검증: 초안으로 관 11 → 10개 저장·초안 비움, 되돌려 11개 복구. 테스트 390 통과.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-06 20:25:12 +09:00

34 lines
1.7 KiB
TypeScript

/* =============================================================================
* B05_Profile_Api_Pipes_Draft.ts
* B05 배수유역도에서 고친 **관 목록 초안**(세션) — [저장]·[확정]에서만 정본으로 나간다.
*
* 왜 생겼나(2026-09-06 대응표 조사) — 관 추가·이동·삭제가 패널 메모리에만 있어, B06 으로
* 넘어가 [저장]하면 그 편집이 통째로 사라졌다(`savePipes()` 를 부르는 곳이 B05 [임시저장]
* 하나뿐이었다). 다른 조작값과 같은 규칙으로 세션에 쌓고 저장 앞단에서 함께 내보낸다.
*
* 자동저장은 하지 않는다(CLAUDE.md 5장).
* ========================================================================== */
import { readState, writeState } from "../A00_Common/b_page_state";
import { saveDetailPipePoints } from "../B04_PreProcess/B04_PreProcess_Api_Fetch";
import type { DetailPipeInput } from "../B04_PreProcess/B04_PreProcess_Api_Fetch";
/** 세션에 담는 관 한 벌 — 정본 PUT 이 그대로 받는 꼴이다. */
export type PendingPipes = DetailPipeInput[];
export function readPendingPipes(projectId: string): PendingPipes | null {
return readState<PendingPipes>("pipes", projectId);
}
export function writePendingPipes(projectId: string, next: PendingPipes | null): void {
writeState("pipes", next, projectId);
}
/** 초안이 있으면 정본에 쓰고 비운다. 없으면 아무 일도 하지 않는다. */
export async function flushPendingPipes(projectId: string): Promise<void> {
const pending = readPendingPipes(projectId);
if (!pending) return;
await saveDetailPipePoints(projectId, pending);
writePendingPipes(projectId, null);
}