swiperclocklaunch: remove `swipeHandler`, operate outside of `setUI`

pull/3489/head
Rob Pilling 2024-07-04 12:18:30 +01:00
parent 72658828ac
commit 89f39af200
1 changed files with 8 additions and 6 deletions

View File

@ -3,19 +3,21 @@
var oldSwipe; var oldSwipe;
Bangle.setUI = function(mode, cb) { Bangle.setUI = function(mode, cb) {
if (oldSwipe && oldSwipe !== Bangle.swipeHandler) if (oldSwipe) {
Bangle.removeListener("swipe", oldSwipe); Bangle.removeListener("swipe", oldSwipe);
oldSwipe = undefined;
}
sui(mode,cb); sui(mode,cb);
oldSwipe = Bangle.swipeHandler;
if (Bangle.CLOCK) { if (Bangle.CLOCK) {
// clock -> launcher // clock -> launcher
Bangle.swipeHandler = dir => { if (dir<0) Bangle.showLauncher(); }; oldSwipe = dir => { if (dir<0) Bangle.showLauncher(); };
Bangle.on("swipe", Bangle.swipeHandler); Bangle.on("swipe", oldSwipe);
} else if (global.__FILE__ && __FILE__.endsWith(".app.js") && (require("Storage").readJSON(__FILE__.slice(0,-6)+"info",1)||{}).type==="launch") { } else if (global.__FILE__ && __FILE__.endsWith(".app.js") && (require("Storage").readJSON(__FILE__.slice(0,-6)+"info",1)||{}).type==="launch") {
// launcher -> clock // launcher -> clock
Bangle.swipeHandler = dir => { if (dir>0) load(); }; oldSwipe = dir => { if (dir>0) load(); };
Bangle.on("swipe", Bangle.swipeHandler); Bangle.on("swipe", oldSwipe);
} }
}; };
})(); })();