Merge pull request #1266 from thecodingmachine/UpdateSetPropertyLayer

SetProperty delete a property where tha value is undefined and load the map of exitUrl property
This commit is contained in:
David Négrier 2021-07-07 16:44:32 +02:00 committed by GitHub
commit 0a1c01fb26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1077,14 +1077,24 @@ ${escapedMessage}
console.warn('Could not find layer "' + layerName + '" when calling setProperty'); console.warn('Could not find layer "' + layerName + '" when calling setProperty');
return; return;
} }
if (propertyName === "exitUrl" && typeof propertyValue === "string") {
this.loadNextGame(propertyValue);
}
if (layer.properties === undefined) { if (layer.properties === undefined) {
layer.properties = []; layer.properties = [];
} }
const property = layer.properties.find((property) => property.name === propertyName); const property = layer.properties.find((property) => property.name === propertyName);
if (property === undefined) { if (property === undefined) {
if (propertyValue === undefined) {
return;
}
layer.properties.push({ name: propertyName, type: typeof propertyValue, value: propertyValue }); layer.properties.push({ name: propertyName, type: typeof propertyValue, value: propertyValue });
return; return;
} }
if (propertyValue === undefined) {
const index = layer.properties.indexOf(property);
layer.properties.splice(index, 1);
}
property.value = propertyValue; property.value = propertyValue;
} }