swiperclocklaunch: ensure we clear old listeners too

Previously we wouldn't clear old listeners, which meant that they'd
remain hanging around, potentially interfering with the currently shown
app/clock. We now remember to clear them too, so setUI behaves as a
proper reset.

See #2809 for more details.
pull/2809/head
Rob Pilling 2023-06-11 14:36:40 +01:00
parent 7fa165f421
commit 5ca4db69d7
1 changed files with 6 additions and 0 deletions

View File

@ -1,7 +1,13 @@
(function() {
var sui = Bangle.setUI;
var oldSwipe;
Bangle.setUI = function(mode, cb) {
if (oldSwipe && oldSwipe !== Bangle.swipeHandler)
Bangle.removeListener("swipe", oldSwipe);
sui(mode,cb);
oldSwipe = Bangle.swipeHandler;
if(!mode) return;
if ("object"==typeof mode) mode = mode.mode;
if (mode.startsWith("clock")) {