From 77244761283838e32c27620d59b3653c96a8afed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Tue, 8 Dec 2020 20:34:05 +0100 Subject: [PATCH] onWallConfigUpdate now accounts for the fact that wall ids aren't globally unique --- CHANGELOG.md | 1 + main.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b351ba2..7ed28c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### Bugfixes - In cloned scenes Locked Door Alerts will now only highlight the door in the correct scene +- When adding a door to a synchronization group it will now assume the correct state if it's being synchronized with it's twin door on a cloned map ## v1.0.1 - When adding a door to a synchronization group adjust it's state to bring it in sync with the other doors diff --git a/main.js b/main.js index 7fcf793..1f8f04e 100644 --- a/main.js +++ b/main.js @@ -151,7 +151,19 @@ async function onWallConfigUpdate(event, formData) { // If a synchronization group is set, get the state of existing doors and assume their state if (formData.synchronizationGroup) { - const doorInGroup = findInAllWalls(wall => wall.door && wall.flags.smartdoors?.synchronizationGroup == formData.synchronizationGroup && !ids.includes(wall._id)); + // Search for other doors in the synchronization group that aren't in the list of edited doors + const doorInGroup = findInAllWalls(wall => { + // We only search for doors + if (!wall.door) + return false + // We only want doors in the same synchronization group + if (wall.flags.smartdoors?.synchronizationGroup !== formData.synchronizationGroup) + return false + // Doors on this scene that have their id included in `ids` are currently being changed. Ignore them. + if (wall.scene === canvas.scene && ids.includes(wall._id)) + return false + return true + }) if (doorInGroup) updateData.ds = doorInGroup.ds; }