backswipe: ignore `undefined` handlers

`undefined` handlers are created when we [remove listeners] part-way
through the array. This fixes `backswipe` for all firmwares, but
leaves the door open for a potential firmware change.

[remove listeners]: 0f16231a43/src/jswrap_object.c (L1035-L1035)
pull/3041/head
Rob Pilling 2023-10-10 10:50:07 +01:00
parent 8a4a2cee5a
commit 70b89fbe2f
3 changed files with 3 additions and 2 deletions

View File

@ -1,2 +1,3 @@
0.01: New App!
0.02: Don't fire if the app uses swipes already.
0.03: Only count defined handlers in the handler array.

View File

@ -26,7 +26,7 @@
if (Bangle["#on"+eventType] === undefined) {
return 0;
} else if (Bangle["#on"+eventType] instanceof Array) {
return Bangle["#on"+eventType].length;
return Bangle["#on"+eventType].filter(x=>x).length;
} else if (Bangle["#on"+eventType] !== undefined) {
return 1;
}

View File

@ -1,7 +1,7 @@
{ "id": "backswipe",
"name": "Back Swipe",
"shortName":"BackSwipe",
"version":"0.02",
"version":"0.03",
"description": "Service that allows you to use an app's back button using left to right swipe gesture",
"icon": "app.png",
"tags": "back,gesture,swipe",