From 14a37529c9bacb3506e24e43b15cd001d70092c4 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Wed, 3 Jul 2024 12:07:45 +0100 Subject: [PATCH] swiperclocklaunch: fix detection of clock --- apps/swiperclocklaunch/ChangeLog | 1 + apps/swiperclocklaunch/boot.js | 15 +++++---------- apps/swiperclocklaunch/metadata.json | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/apps/swiperclocklaunch/ChangeLog b/apps/swiperclocklaunch/ChangeLog index a341ee512..06c7577bc 100644 --- a/apps/swiperclocklaunch/ChangeLog +++ b/apps/swiperclocklaunch/ChangeLog @@ -4,3 +4,4 @@ 0.04: Update to work with new 'fast switch' clock->launcher functionality 0.05: Keep track of event listeners we "overwrite", and remove them at the start of setUI 0.06: Handle apps that call setUI({}) to reset +0.07: Use a more reliable method of detecting a clock diff --git a/apps/swiperclocklaunch/boot.js b/apps/swiperclocklaunch/boot.js index bb033891e..8f5408ee5 100644 --- a/apps/swiperclocklaunch/boot.js +++ b/apps/swiperclocklaunch/boot.js @@ -8,19 +8,14 @@ sui(mode,cb); oldSwipe = Bangle.swipeHandler; - if ("object"==typeof mode) mode = mode.mode; - if (!mode) return; - - if (mode.startsWith("clock")) { + if (Bangle.CLOCK) { // clock -> launcher Bangle.swipeHandler = dir => { if (dir<0) Bangle.showLauncher(); }; Bangle.on("swipe", Bangle.swipeHandler); - } else { - if (global.__FILE__ && __FILE__.endsWith(".app.js") && (require("Storage").readJSON(__FILE__.slice(0,-6)+"info",1)||{}).type=="launch") { - // launcher -> clock - Bangle.swipeHandler = dir => { if (dir>0) load(); }; - Bangle.on("swipe", Bangle.swipeHandler); - } + } else if (global.__FILE__ && __FILE__.endsWith(".app.js") && (require("Storage").readJSON(__FILE__.slice(0,-6)+"info",1)||{}).type==="launch") { + // launcher -> clock + Bangle.swipeHandler = dir => { if (dir>0) load(); }; + Bangle.on("swipe", Bangle.swipeHandler); } }; })(); diff --git a/apps/swiperclocklaunch/metadata.json b/apps/swiperclocklaunch/metadata.json index 436d36868..d474b38e3 100644 --- a/apps/swiperclocklaunch/metadata.json +++ b/apps/swiperclocklaunch/metadata.json @@ -1,7 +1,7 @@ { "id": "swiperclocklaunch", "name": "Swiper Clock Launch", - "version": "0.06", + "version": "0.07", "description": "Navigate between clock and launcher with Swipe action", "icon": "swiperclocklaunch.png", "type": "bootloader",