From 24110181c6ff6a4b3773363ae27698767b8e358c Mon Sep 17 00:00:00 2001 From: KraPete <86825564+KraPete@users.noreply.github.com> Date: Mon, 16 Dec 2024 09:54:48 +0500 Subject: [PATCH] Remove obsolete code in SVG dashboards (#677) Remove parts of legacy switch handling core in SVG dashboards --- .../view-svg-dashboard/pageStore.js | 24 +++++++------------ debian/changelog | 6 +++++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/scripts/react-directives/view-svg-dashboard/pageStore.js b/app/scripts/react-directives/view-svg-dashboard/pageStore.js index 4b81e2bd..0e07a83e 100644 --- a/app/scripts/react-directives/view-svg-dashboard/pageStore.js +++ b/app/scripts/react-directives/view-svg-dashboard/pageStore.js @@ -15,7 +15,6 @@ class ViewSvgDashboardPageStore { this.editFn = null; this.moveToDashboardFn = null; this.dashboardId = null; - this.switchValueFn = null; this.key = Math.random(); this.dashboardIndex = 0; this.editAccessLevelStore = new AccessLevelStore(rolesFactory); @@ -51,10 +50,6 @@ class ViewSvgDashboardPageStore { this.channelValues, id => this?.editFn(id), id => this.moveToDashboard(id), - (channel, value) => { - let cell = this.deviceData.cell(channel); - cell.value = cell.value == value.on ? value.off : value.on; - }, (channel, value) => this.switchValue(channel, value) ); store.setForceFullscreen(this.forceFullscreen); @@ -112,8 +107,15 @@ class ViewSvgDashboardPageStore { } switchValue(channel, value) { - let cell = this.deviceData.cell(channel); - cell.value = cell.value == value.on ? value.off : value.on; + if (!this.deviceData) { + return; + } + try { + const cell = this.deviceData.cell(channel); + cell.value = cell.value === value.on ? value.off : value.on; + } catch (e) { + // Do nothing if cell is not found + } } editDashboard() { @@ -128,14 +130,6 @@ class ViewSvgDashboardPageStore { this.moveToDashboardFn = moveToDashboardFn; } - setSwitchValueFn(switchValueFn) { - this.switchValueFn = switchValueFn; - } - - switchValue(channel, value) { - this?.switchValueFn(channel, value); - } - moveToDashboard(dashboardId) { if (this.dashboardId != dashboardId) { this.setLoading(true); diff --git a/debian/changelog b/debian/changelog index 31129743..9f172f38 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +wb-mqtt-homeui (2.107.2) stable; urgency=medium + + * Fix switch handling in SVG dashboards + + -- Petr Krasnoshchekov Fri, 13 Dec 2024 12:19:22 +0500 + wb-mqtt-homeui (2.107.1) stable; urgency=medium * Fix mqtt channels value cell's width