[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.
pull/1844/head
storm64 2022-05-18 13:00:53 +02:00
parent 8102fd4e72
commit dde4cc1562
3 changed files with 3 additions and 2 deletions

View File

@ -8,3 +8,4 @@
0.09: Vibrate on connection loss 0.09: Vibrate on connection loss
0.10: Bug fix 0.10: Bug fix
0.11: Avoid too many notifications. Change disconnected colour to red. 0.11: Avoid too many notifications. Change disconnected colour to red.
0.12: Prevent repeated execution of `draw()` from the current app.

View File

@ -1,7 +1,7 @@
{ {
"id": "widbt_notify", "id": "widbt_notify",
"name": "Bluetooth Widget with Notification", "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.", "description": "Show the current Bluetooth connection status in the top right of the clock and vibrate when disconnected.",
"icon": "widget.png", "icon": "widget.png",
"type": "widget", "type": "widget",

View File

@ -28,7 +28,7 @@ WIDGETS.bluetooth_notify = {
disconnect: function() { disconnect: function() {
if(WIDGETS.bluetooth_notify.warningEnabled == 1){ if(WIDGETS.bluetooth_notify.warningEnabled == 1){
E.showMessage(/*LANG*/'Connection\nlost.', 'Bluetooth'); 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; WIDGETS.bluetooth_notify.warningEnabled = 0;
setTimeout('WIDGETS.bluetooth_notify.warningEnabled = 1;', 30000); // don't buzz for the next 30 seconds. setTimeout('WIDGETS.bluetooth_notify.warningEnabled = 1;', 30000); // don't buzz for the next 30 seconds.