From aad6513989e2ae702c788ed4582f294003a66c80 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Mon, 11 Sep 2023 14:56:57 +0100 Subject: [PATCH] lightswitch 0.08: Ensure boot code doesn't allocate and leave a gloval variable named 'settings' --- apps/lightswitch/ChangeLog | 1 + apps/lightswitch/boot.js | 7 +++---- apps/lightswitch/metadata.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/lightswitch/ChangeLog b/apps/lightswitch/ChangeLog index 4f62ab799..398d146e0 100644 --- a/apps/lightswitch/ChangeLog +++ b/apps/lightswitch/ChangeLog @@ -5,3 +5,4 @@ 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 diff --git a/apps/lightswitch/boot.js b/apps/lightswitch/boot.js index d57679b56..dba51bce1 100644 --- a/apps/lightswitch/boot.js +++ b/apps/lightswitch/boot.js @@ -1,5 +1,6 @@ +{ // load settings -var settings = Object.assign({ +let settings = Object.assign({ value: 1, isOn: true }, require("Storage").readJSON("lightswitch.json", true) || {}); @@ -12,6 +13,4 @@ Bangle.removeListener("tap", require("lightswitch.js").tapListener); // add tap listener to unlock and/or flash backlight if (settings.unlockSide || settings.tapSide) Bangle.on("tap", require("lightswitch.js").tapListener); - -// clear variable -settings = undefined; +} diff --git a/apps/lightswitch/metadata.json b/apps/lightswitch/metadata.json index f1f0160b8..f33f6d1cb 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.07", + "version": "0.08", "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": [