From 5ca4db69d7636ee9578ab1366911ea886f754fb8 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Sun, 11 Jun 2023 14:36:40 +0100 Subject: [PATCH] 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. --- apps/swiperclocklaunch/boot.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/swiperclocklaunch/boot.js b/apps/swiperclocklaunch/boot.js index ea00a6735..11abb84c9 100644 --- a/apps/swiperclocklaunch/boot.js +++ b/apps/swiperclocklaunch/boot.js @@ -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")) {