import { OVERWORLD_ID, normalizeDimensionId } from "../../../shared/world/dimensions.js"; /** * Editor chunk saves and reloads share the same `EDITOR_CHUNK` reply. * After `EDITOR_SAVE_CHUNK` the local draft is still dirty (baseline is not * updated until the ack is applied). Treating that ack like a reconnect reload * leaves the Save button dirty even though the server already persisted. */ export function editorChunkSaveKey (dimensionId, chunkX, chunkY) { return `${normalizeDimensionId(dimensionId ?? OVERWORLD_ID)}:${chunkX | 0},${chunkY | 0}`; } /** * Whether an incoming selected-chunk `EDITOR_CHUNK` should replace the local draft. * Save acks must apply even while dirty. Non-ack reloads must not wipe unsaved paint. * * @param {{ isSaveAck?: boolean, isDirty?: boolean }} options */ export function shouldApplySelectedEditorChunk ({ isSaveAck = false, isDirty = false } = {}) { return !!isSaveAck || !isDirty; }