iconlaunch - Cleanup and reset timeout as needed

pull/2236/head
Martin Boonk 2022-11-06 12:42:11 +01:00
parent 5c110a89fb
commit 81632cda7e
1 changed files with 10 additions and 1 deletions

View File

@ -133,6 +133,7 @@
g.flip(); g.flip();
const itemsN = Math.ceil(launchCache.apps.length / appsN); const itemsN = Math.ceil(launchCache.apps.length / appsN);
let onDrag = function(e) { let onDrag = function(e) {
updateTimeout();
g.setColor(g.theme.fg); g.setColor(g.theme.fg);
g.setBgColor(g.theme.bg); g.setBgColor(g.theme.bg);
let dy = e.dy; let dy = e.dy;
@ -182,6 +183,7 @@
drag: onDrag, drag: onDrag,
touch: (_, e) => { touch: (_, e) => {
if (e.y < R.y - 4) return; if (e.y < R.y - 4) return;
updateTimeout();
let i = YtoIdx(e.y); let i = YtoIdx(e.y);
selectItem(i, e); selectItem(i, e);
}, },
@ -202,16 +204,23 @@
delete idxToY; delete idxToY;
delete YtoIdx; delete YtoIdx;
delete settings; delete settings;
if (timeout) clearTimeout(timeout);
setTimeout(eval, 0, s.read(".bootcde")); setTimeout(eval, 0, s.read(".bootcde"));
}; };
if (settings.oneClickExit) mode.btn = returnToClock; if (settings.oneClickExit) mode.btn = returnToClock;
let timeout;
const updateTimeout = function(){
if (settings.timeOut!="Off"){ if (settings.timeOut!="Off"){
let time=parseInt(settings.timeOut); //the "s" will be trimmed by the parseInt let time=parseInt(settings.timeOut); //the "s" will be trimmed by the parseInt
setTimeout(returnToClock,time*1000); if (timeout) clearTimeout(timeout);
timeout = setTimeout(returnToClock,time*1000);
}
} }
updateTimeout();
Bangle.setUI(mode); Bangle.setUI(mode);
} }