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