init replay mode draft

This commit is contained in:
taDuc
2026-05-16 12:08:21 +07:00
parent a8097c95d4
commit 7424bc43b0
8 changed files with 592 additions and 166 deletions
+3 -25
View File
@@ -3,7 +3,7 @@ import { normalizeGeoTypeKey, typeKeyToGeoTypeCode } from "@/uhm/lib/map/geo/geo
import type { Change } from "@/uhm/lib/editor/draft/editorTypes";
import type { EntitySnapshot } from "@/uhm/types/entities";
import type { EntitySnapshotOperation } from "@/uhm/types/entities";
import type { Feature, FeatureCollection, Geometry, GeometryEntitySnapshot, GeometrySnapshot } from "@/uhm/types/geo";
import type { Feature, FeatureCollection, GeometryEntitySnapshot, GeometrySnapshot } from "@/uhm/types/geo";
import type { BattleReplay, EditorSnapshot, Project } from "@/uhm/types/projects";
import type { WikiSnapshot } from "@/uhm/types/wiki";
@@ -25,20 +25,6 @@ interface RawEntityRow extends UnknownRecord {
status?: number;
}
interface RawGeometryRow extends UnknownRecord {
id?: string | number;
operation?: string;
source?: string;
ref?: { id?: string };
type?: string | number;
geo_type?: string | number;
draw_geometry?: Geometry;
geometry?: Geometry;
binding?: string[];
time_start?: number;
time_end?: number;
}
interface RawWikiRow extends UnknownRecord {
id?: string;
operation?: string;
@@ -364,9 +350,9 @@ export function buildEditorSnapshot(options: {
if (prev.source !== "inline") continue;
// Carry forward as current-state inline entity; operation is a per-commit delta signal.
const cloned = JSON.parse(JSON.stringify(prev)) as EntitySnapshot;
const { operation: _op, ...rest } = cloned;
delete cloned.operation;
entityRows.set(id, {
...rest,
...cloned,
id,
source: "inline",
operation: "reference",
@@ -689,14 +675,6 @@ export function toApiEditorSnapshot(snapshot: EditorSnapshot): EditorSnapshot {
});
}
if (Array.isArray(cloned.replays)) {
cloned.replays = cloned.replays.map((replay) => {
// Strip local-only replay_features before sending to BE
const { replay_features: _, ...rest } = replay;
return rest;
});
}
return cloned;
}