diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a6e736..ae6054c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ### Other - Smart Doors is now compatible with Arms Reach diff --git a/src/features/synchronized_doors.js b/src/features/synchronized_doors.js index fd63b31..c9118fd 100644 --- a/src/features/synchronized_doors.js +++ b/src/features/synchronized_doors.js @@ -121,12 +121,13 @@ export function onDoorRightClick() { } // 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 let scenes = Util.filterAllWalls(wall => wall.door && wall.flags.smartdoors?.synchronizationGroup === synchronizationGroup); // Update all doors in the synchronization group - scenes.forEach((scene) => { - scene.scene.updateEmbeddedEntity("Wall", scene.walls.map((wall) => {return {_id: wall._id, ...updateData}})) - }) + for (const scene of scenes) { + // 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}})) + } }