From 375c691b6cd9d6a8f86d30d9663411405d891bbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Giovanni=20Borella?= Date: Tue, 27 May 2025 09:02:53 +0200 Subject: [PATCH] Improve stability of turnOn/turnOff Add optional chaining to remove errors when trying to turn off a layer that is already off etc. --- browser/modules/switchLayer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/browser/modules/switchLayer.js b/browser/modules/switchLayer.js index 05aa8a36a..4734899a0 100644 --- a/browser/modules/switchLayer.js +++ b/browser/modules/switchLayer.js @@ -67,13 +67,13 @@ module.exports = module.exports = { // Expose init in global scope api.turnOn = (l) => { const status = _self.getLayersEnabledStatus(); - if (!status?.[l] || !status[l].enabled) { + if (!status?.[l] || !status?.[l]?.enabled) { _self.init(l, true); } } api.turnOff = (l) => { const status = _self.getLayersEnabledStatus(); - if (status[l].enabled) { + if (status?.[l]?.enabled) { _self.init(l, false); } }