onWallConfigUpdate now accounts for the fact that wall ids aren't globally unique

This commit is contained in:
2020-12-08 20:34:05 +01:00
parent 597ede53ab
commit 7724476128
2 changed files with 14 additions and 1 deletions

14
main.js
View File

@@ -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;
}