Skip to content

Commit 7769e7f

Browse files
author
thyttan
committed
messagegui: fix clear hw btn handler, etc
1 parent 009ce41 commit 7769e7f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

apps/messagegui/app.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ function showMessagesScroller(msg, persist, alreadyProcessed) {
390390
// Zero ms timeout as to not move on before the scroller has registered the emitted drag event.
391391
setTimeout(()=>{
392392
E.showScroller();
393-
if (BTN_EXT_SELECT) {clearWatch(BTN_EXT_SELECT); delete BTN_EXT_SELECT;}
393+
clearBtnHandler();
394394
showMessagesScroller(MESSAGES[idx],
395395
true, alreadyProcessed);
396396
},0);
@@ -416,18 +416,24 @@ function showMessagesScroller(msg, persist, alreadyProcessed) {
416416
select : function(scrollIdx, touch) {
417417
WU.show();
418418
const MSG_SELECT = identifyDisplayedMsg(scrollIdx);
419-
if (BTN_EXT_SELECT) {clearWatch(BTN_EXT_SELECT); delete BTN_EXT_SELECT;}
419+
clearBtnHandler();
420420
if (!touch) {showMessageRouter(MSG_SELECT, "scrollerSelect"); return;}
421421
if (touch.type == 0) {showMessageRouter(MSG_SELECT,"scrollerSelect");}
422422
if (touch.type == 2) {showMessageSettings(MSG_SELECT);}
423423
}
424424
});
425425

426+
function clearBtnHandler() {
427+
if (Bangle.btnHandler) {clearWatch(Bangle.btnHandler); Bangle.btnHandler=undefined;}
428+
}
429+
clearBtnHandler();
430+
426431
// If Bangle.js 2 add an external select hw button handler.
427-
const BTN_EXT_SELECT = ((2===process.env.HWVERSION) && (setWatch(()=>{
432+
Bangle.btnHandler = ((2===process.env.HWVERSION) && (setWatch(()=>{
428433
Bangle.emit("drag", {dy:0}); // Compatibility with `kineticscroll`, stopping the scroller so it doesn't continue scrolling when the `showMessageOverview` screen is loaded.
429434
// Zero ms timeout as to not move on before the scroller has registered the emitted drag event.
430435
setTimeout(()=>{
436+
if ("messagegui.new.js"===global.__FILE__) {return load();}
431437
const SCROLL_IDX_CENTER_SCREEN = prevScrollIdxs[0]>prevScrollIdxs[1] ?
432438
prevScrollIdxs[0]-LINES_PER_SCREEN/2:prevScrollIdxs[0]+LINES_PER_SCREEN/2;
433439
WU.show();

0 commit comments

Comments
 (0)