From c5b5326480c1587f9616225d3d5af55dd437199c Mon Sep 17 00:00:00 2001 From: GRL Date: Fri, 2 Jul 2021 14:40:18 +0200 Subject: [PATCH] setProperty function doesn't set an empty array if property doesn't exist --- CONTRIBUTING.md | 2 +- front/src/Phaser/Game/GameScene.ts | 6 ++++-- maps/tests/Metadata/setTiles.json | 5 ----- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b85d0a98..8bbbc93e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,7 +42,7 @@ Before committing, be sure to install the "Prettier" precommit hook that will re In order to enable the "Prettier" precommit hook, at the root of the project, run: ```console -$ yarn run install +$ yarn install $ yarn run prepare ``` diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 19da51a0..3fbf79a4 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -1075,11 +1075,13 @@ ${escapedMessage} console.warn('Could not find layer "' + layerName + '" when calling setProperty'); return; } - const property = (layer.properties as ITiledMapLayerProperty[])?.find( + if (layer.properties === undefined) { + layer.properties = []; + } + const property = (layer.properties as ITiledMapLayerProperty[]).find( (property) => property.name === propertyName ); if (property === undefined) { - layer.properties = []; layer.properties.push({ name: propertyName, type: typeof propertyValue, value: propertyValue }); return; } diff --git a/maps/tests/Metadata/setTiles.json b/maps/tests/Metadata/setTiles.json index 5b281a15..7eb9791a 100644 --- a/maps/tests/Metadata/setTiles.json +++ b/maps/tests/Metadata/setTiles.json @@ -286,11 +286,6 @@ "name":"jitsiTrigger", "type":"string", "value":"onaction" - }, - { - "name":"jitsiUrl", - "type":"string", - "value":"meet.jit.si" }] }, {