From dde4cc1562e0b181f58c18e545fce28d273c1ec5 Mon Sep 17 00:00:00 2001 From: storm64 Date: Wed, 18 May 2022 13:00:53 +0200 Subject: [PATCH] [widbt_notify] Prevent repeated `draw()` Replace `setInterval` with `setTimeout` to clear the `Connection lost.`-message to prevent repeatedly calling of `draw()` from the current app/clock. --- apps/widbt_notify/ChangeLog | 1 + apps/widbt_notify/metadata.json | 2 +- apps/widbt_notify/widget.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/widbt_notify/ChangeLog b/apps/widbt_notify/ChangeLog index b5a50210e..3708089c1 100644 --- a/apps/widbt_notify/ChangeLog +++ b/apps/widbt_notify/ChangeLog @@ -8,3 +8,4 @@ 0.09: Vibrate on connection loss 0.10: Bug fix 0.11: Avoid too many notifications. Change disconnected colour to red. +0.12: Prevent repeated execution of `draw()` from the current app. diff --git a/apps/widbt_notify/metadata.json b/apps/widbt_notify/metadata.json index 0b795c2c8..0a144ade1 100644 --- a/apps/widbt_notify/metadata.json +++ b/apps/widbt_notify/metadata.json @@ -1,7 +1,7 @@ { "id": "widbt_notify", "name": "Bluetooth Widget with Notification", - "version": "0.11", + "version": "0.12", "description": "Show the current Bluetooth connection status in the top right of the clock and vibrate when disconnected.", "icon": "widget.png", "type": "widget", diff --git a/apps/widbt_notify/widget.js b/apps/widbt_notify/widget.js index 47765f3d0..fd088c670 100644 --- a/apps/widbt_notify/widget.js +++ b/apps/widbt_notify/widget.js @@ -28,7 +28,7 @@ WIDGETS.bluetooth_notify = { disconnect: function() { if(WIDGETS.bluetooth_notify.warningEnabled == 1){ E.showMessage(/*LANG*/'Connection\nlost.', 'Bluetooth'); - setInterval(()=>{WIDGETS.bluetooth_notify.redrawCurrentApp();}, 3000); // clear message - this will reload the widget, resetting 'warningEnabled'. + setTimeout(()=>{WIDGETS.bluetooth_notify.redrawCurrentApp();}, 3000); // clear message - this will reload the widget, resetting 'warningEnabled'. WIDGETS.bluetooth_notify.warningEnabled = 0; setTimeout('WIDGETS.bluetooth_notify.warningEnabled = 1;', 30000); // don't buzz for the next 30 seconds.