Fix a race condition that may cause doors to not synchronize across scenes

This commit is contained in:
2021-02-11 23:03:18 +01:00
parent 69b6542a18
commit aafa18a2c2
2 changed files with 9 additions and 4 deletions

View File

@@ -1,3 +1,7 @@
## In development
### Bugfix
- Fixed a race condition that may cause doors to not be properly synchronized across scenes
## v1.2.3 ## v1.2.3
### Other ### Other
- Smart Doors is now compatible with Arms Reach - Smart Doors is now compatible with Arms Reach

View File

@@ -121,12 +121,13 @@ export function onDoorRightClick() {
} }
// Updates all doors in the specified synchronization group with the provided data // Updates all doors in the specified synchronization group with the provided data
function updateSynchronizedDoors(updateData, synchronizationGroup) { async function updateSynchronizedDoors(updateData, synchronizationGroup) {
// Search for doors belonging to the synchronization group in all scenes // Search for doors belonging to the synchronization group in all scenes
let scenes = Util.filterAllWalls(wall => wall.door && wall.flags.smartdoors?.synchronizationGroup === synchronizationGroup); let scenes = Util.filterAllWalls(wall => wall.door && wall.flags.smartdoors?.synchronizationGroup === synchronizationGroup);
// Update all doors in the synchronization group // Update all doors in the synchronization group
scenes.forEach((scene) => { for (const scene of scenes) {
scene.scene.updateEmbeddedEntity("Wall", scene.walls.map((wall) => {return {_id: wall._id, ...updateData}})) // When VFTT 0.8 is out look for a way to do this in a single call.
}) await scene.scene.updateEmbeddedEntity("Wall", scene.walls.map((wall) => {return {_id: wall._id, ...updateData}}))
}
} }