Skip to content

Commit 6d9c85d

Browse files
author
thyttan
committed
swipeinv: read number of set apps correctly
1 parent cef2078 commit 6d9c85d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

apps/swipeinv/boot.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@
44
apps: []
55
}, require("Storage").readJSON("swipeinv.json", true) || {});
66

7-
let getAppIdFromSrc = ()=> { return global.__FILE__.split(".")[0]; }
7+
let getAppIdFromSrc = ()=> {
8+
return global.__FILE__ && global.__FILE__.split(".")[0];
9+
}
810

911
setTimeout(() => { // Timeout so we prepend listeners late, hopefully after all other listerners were added.
10-
if (settings.global || settings.apps.length > 0) {
12+
if (settings.global || Object.keys(settings.apps).length > 0) {
1113

1214
let swipeInverter = (dirLR, dirUD, obj) => {
1315
if (settings.global ^ Object.keys(settings.apps).includes(getAppIdFromSrc())) {
1416
if (!(obj && obj.inverted)) {
1517
E.stopEventPropagation();
1618
obj = Object.assign({inverted:true}, obj);
1719

18-
if (settings.global ^ settings.apps[getAppIdFromSrc].swipeH) {dirLR *= -1;}
19-
if (settings.global ^ settings.apps[getAppIdFromSrc].swipeV) {dirUD *= -1;}
20+
if (settings.global ^ (settings.apps[getAppIdFromSrc()]&&settings.apps[getAppIdFromSrc()].swipeH)) {dirLR *= -1;}
21+
if (settings.global ^ (settings.apps[getAppIdFromSrc()]&&settings.apps[getAppIdFromSrc()].swipeV)) {dirUD *= -1;}
2022

2123
Bangle.emit("swipe", dirLR, dirUD, obj)
2224
}
@@ -29,8 +31,8 @@
2931
E.stopEventPropagation();
3032
e.inverted = true;
3133

32-
if (settings.global ^ settings.apps[getAppIdFromSrc].dragH) {e.dx *= -1;}
33-
if (settings.global ^ settings.apps[getAppIdFromSrc].dragV) {e.dy *= -1;}
34+
if (settings.global ^ (settings.apps[getAppIdFromSrc()]&&settings.apps[getAppIdFromSrc()].dragH)) {e.dx *= -1;}
35+
if (settings.global ^ (settings.apps[getAppIdFromSrc()]&&settings.apps[getAppIdFromSrc()].dragV)) {e.dy *= -1;}
3436

3537
Bangle.emit("drag", e);
3638
}

0 commit comments

Comments
 (0)