From 8209dcbf287b4e90f1decfc9010b04f273be89e0 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Mon, 11 Sep 2023 17:51:39 +0100 Subject: [PATCH] lightswitch: fix tap listener widget assumption --- apps/lightswitch/ChangeLog | 3 ++- apps/lightswitch/lib.js | 4 ++-- apps/lightswitch/metadata.json | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/lightswitch/ChangeLog b/apps/lightswitch/ChangeLog index 398d146e0..a14d85e21 100644 --- a/apps/lightswitch/ChangeLog +++ b/apps/lightswitch/ChangeLog @@ -5,4 +5,5 @@ 0.05: Prevent drawing into app area. 0.06: Fix issue where .draw was being called by reference (not allowing widgets to be hidden) 0.07: Handle the swipe event that is generated when draging to change light intensity, so it doesn't trigger some other swipe handler. -0.08: Ensure boot code doesn't allocate and leave a gloval variable named 'settings' \ No newline at end of file +0.08: Ensure boot code doesn't allocate and leave a gloval variable named 'settings' +0.09: Handle lightswitch logic running before its widget has loaded diff --git a/apps/lightswitch/lib.js b/apps/lightswitch/lib.js index eb720e69a..3dd07579c 100644 --- a/apps/lightswitch/lib.js +++ b/apps/lightswitch/lib.js @@ -6,7 +6,7 @@ exports = { // check for double tap and direction if (data.double) { // setup shortcut to this widget or load from storage - var w = global.WIDGETS ? WIDGETS.lightswitch : Object.assign({ + var w = global.WIDGETS && WIDGETS.lightswitch || Object.assign({ unlockSide: "", tapSide: "right", tapOn: "always", @@ -31,7 +31,7 @@ exports = { // function to flash backlight flash: function(tOut) { // setup shortcut to this widget or load from storage - var w = global.WIDGETS ? WIDGETS.lightswitch : Object.assign({ + var w = global.WIDGETS && WIDGETS.lightswitch || Object.assign({ tOut: 3000, minFlash: 0.2, value: 1, diff --git a/apps/lightswitch/metadata.json b/apps/lightswitch/metadata.json index f33f6d1cb..8eef08952 100644 --- a/apps/lightswitch/metadata.json +++ b/apps/lightswitch/metadata.json @@ -2,7 +2,7 @@ "id": "lightswitch", "name": "Light Switch Widget", "shortName": "Light Switch", - "version": "0.08", + "version": "0.09", "description": "A fast way to switch LCD backlight on/off, change the brightness and show the lock status. All in one widget.", "icon": "images/app.png", "screenshots": [