Skip to content

Commit 4696b43

Browse files
author
thyttan
committed
swipeinv: look up filename less often
1 parent bfb8c93 commit 4696b43

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

apps/swipeinv/boot.js

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

7-
let getAppIdFromSrc = ()=> {
8-
"ram"
7+
const clockAppID = require("Storage").readJSON("setting.json",true).clock.split(".")[0];
8+
9+
let getAppIdFromCurrentFile = ()=> {
910
if (!global.__FILE__ || global.__FILE__===".bootcde") {
10-
return require("Storage").readJSON("setting.json",true).clock
11+
return clockAppID;
1112
} else {return global.__FILE__.split(".")[0];}
1213
}
1314

@@ -16,13 +17,14 @@
1617

1718
let swipeInverter = (dirLR, dirUD, obj) => {
1819
"ram"
19-
if (settings.global ^ Object.keys(settings.apps).includes(getAppIdFromSrc())) {
20+
const appID = getAppIdFromCurrentFile();
21+
if (settings.global ^ Object.keys(settings.apps).includes(appID)) {
2022
if (!(obj && obj.inverted)) {
2123
E.stopEventPropagation();
2224
obj = Object.assign({inverted:true}, obj);
2325

24-
if (settings.global ^ (settings.apps[getAppIdFromSrc()]&&settings.apps[getAppIdFromSrc()].swipeH)) {dirLR *= -1;}
25-
if (settings.global ^ (settings.apps[getAppIdFromSrc()]&&settings.apps[getAppIdFromSrc()].swipeV)) {dirUD *= -1;}
26+
if (settings.global ^ (settings.apps[appID]&&settings.apps[appID].swipeH)) {dirLR *= -1;}
27+
if (settings.global ^ (settings.apps[appID]&&settings.apps[appID].swipeV)) {dirUD *= -1;}
2628

2729
Bangle.emit("swipe", dirLR, dirUD, obj)
2830
}
@@ -31,13 +33,14 @@
3133

3234
let dragInverter = (e) => {
3335
"ram"
34-
if (settings.global ^ Object.keys(settings.apps).includes(getAppIdFromSrc())) {
36+
const appID = getAppIdFromCurrentFile();
37+
if (settings.global ^ Object.keys(settings.apps).includes(appID)) {
3538
if (!e.inverted) {
3639
E.stopEventPropagation();
3740
e.inverted = true;
3841

39-
if (settings.global ^ (settings.apps[getAppIdFromSrc()]&&settings.apps[getAppIdFromSrc()].dragH)) {e.dx *= -1;}
40-
if (settings.global ^ (settings.apps[getAppIdFromSrc()]&&settings.apps[getAppIdFromSrc()].dragV)) {e.dy *= -1;}
42+
if (settings.global ^ (settings.apps[appID]&&settings.apps[appID].dragH)) {e.dx *= -1;}
43+
if (settings.global ^ (settings.apps[appID]&&settings.apps[appID].dragV)) {e.dy *= -1;}
4144

4245
Bangle.emit("drag", e);
4346
}

0 commit comments

Comments
 (0)