www.spaceplanner.app

Web client to the spaceplanner API
git clone git://jacobedwards.org/www.spaceplanner.app
Log | Files | Refs

commit 0f0e5750fcd35cd218f7505a4f9915e041f981ec
parent 361d9cc127ae828867fb18bbaf07fa4dfb871c11
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Wed,  9 Oct 2024 19:02:11 -0700

Utilize mapID in updateIDs

This required a change to mapID to allow remapping ids.

Diffstat:
Mfiles/floorplans/floorplan/backend.js | 28++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/files/floorplans/floorplan/backend.js b/files/floorplans/floorplan/backend.js @@ -899,20 +899,30 @@ export class FloorplanBackend { return local } - mapID(localID, serverID) { + mapID(localID, serverID, options) { + options = options ?? {} + console.debug("Backend.mapID", localID, serverID) if (localID == null || serverID == null) { throw new Error("Requires local and server ID") } - if (this.serverIDs[localID] === undefined) { - throw new Error("That local ID is already mapped to " + this.serverIDs[localID]) - } - if (this.localIDs[serverID] !== undefined) { - throw new Error("That server ID is already mapped to " + this.localIDs[serverID]) + if (!options.remap) { + if (this.serverIDs[localID] != undefined) { + throw new Error("That local ID is already mapped to " + this.serverIDs[localID]) + } + if (this.localIDs[serverID] != undefined) { + throw new Error("That server ID is already mapped to " + this.localIDs[serverID]) + } } this.localIDs[serverID] = localID this.serverIDs[localID] = serverID } + + remapID(localID, serverID, options) { + options = options ?? {} + options.remap = true + return this.mapID(localID, serverID, options) + } } function gendiff(path, a, b) { @@ -942,11 +952,9 @@ function updateIDs(backend, newdata) { for (let srvID in newdata[t]) { let x = newdata[t][srvID] if (x.old_id != null) { - backend.localIDs[srvID] = x.old_id - backend.serverIDs[x.old_id] = srvID + backend.remapID(x.old_id, srvID) } else { - backend.localIDs[srvID] = srvID - backend.serverIDs[srvID] = srvID + backend.remapID(srvID, srvID) } } }