Fix co website closing on exit zone

This commit is contained in:
Alexis Faizeau 2021-10-07 14:40:02 +02:00
parent 1efcbb4529
commit 1ee0b28f66

View File

@ -37,10 +37,13 @@ export class GameMapPropertiesListener {
} }
}); });
this.gameMap.onPropertyChange("openWebsite", (newValue, oldValue, allProps) => { this.gameMap.onPropertyChange("openWebsite", (newValue, oldValue, allProps) => {
if (newValue === undefined) { const handler = async () => {
if (newValue === undefined || newValue !== oldValue) {
layoutManagerActionStore.removeAction("openWebsite"); layoutManagerActionStore.removeAction("openWebsite");
coWebsiteManager.closeCoWebsite(); await coWebsiteManager.closeCoWebsites();
} else { }
if (newValue !== undefined) {
const openWebsiteFunction = () => { const openWebsiteFunction = () => {
coWebsiteManager.loadCoWebsite( coWebsiteManager.loadCoWebsite(
newValue as string, newValue as string,
@ -49,6 +52,7 @@ export class GameMapPropertiesListener {
allProps.get("openWebsitePolicy") as string | undefined, allProps.get("openWebsitePolicy") as string | undefined,
allProps.get("openWebsiteWidth") as number | undefined allProps.get("openWebsiteWidth") as number | undefined
); );
layoutManagerActionStore.removeAction("openWebsite"); layoutManagerActionStore.removeAction("openWebsite");
}; };
const openWebsiteTriggerValue = allProps.get(TRIGGER_WEBSITE_PROPERTIES); const openWebsiteTriggerValue = allProps.get(TRIGGER_WEBSITE_PROPERTIES);
@ -68,6 +72,9 @@ export class GameMapPropertiesListener {
openWebsiteFunction(); openWebsiteFunction();
} }
} }
};
handler();
}); });
} }
} }