commit 3fc219ae57d480974bcf2b4b668483df25a0c612 parent 0e9e34031c6607333f9ab1790a3f6d95533fd6a8 Author: Jacob R. Edwards <jacob@jacobedwards.org> Date: Tue, 10 Sep 2024 12:36:21 -0700 Set local id in backend.mapID and add more checks Before, this would leave the serverIDs table with local IDs not pointing to server IDs when they should've been. Diffstat:
| M | files/floorplans/floorplan/backend.js | | | 10 | +++++++++- |
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/files/floorplans/floorplan/backend.js b/files/floorplans/floorplan/backend.js @@ -886,10 +886,18 @@ export class FloorplanBackend { } mapID(localID, serverID) { - if (serverID != null && this.localIDs[serverID] !== undefined) { + 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]) } this.localIDs[serverID] = localID + this.serverIDs[localID] = serverID } }