forked from FOSS/BangleApps
bthome 0.04: Fix duplicate button on edit->save
parent
160132d461
commit
12716a172a
|
@ -1,4 +1,5 @@
|
|||
0.01: New App!
|
||||
0.02: Fix double-button press if you press the next button within 30s (#3243)
|
||||
0.03: Cope with identical duplicate buttons (fix #3260)
|
||||
Set 'n' for buttons in Bangle.btHomeData correctly (avoids adding extra buttons on end of advertising)
|
||||
Set 'n' for buttons in Bangle.btHomeData correctly (avoids adding extra buttons on end of advertising)
|
||||
0.04: Fix duplicate button on edit->save
|
|
@ -1,7 +1,7 @@
|
|||
{ "id": "bthome",
|
||||
"name": "BTHome",
|
||||
"shortName":"BTHome",
|
||||
"version":"0.03",
|
||||
"version":"0.04",
|
||||
"description": "Allow your Bangle to advertise with BTHome and send events to Home Assistant via Bluetooth",
|
||||
"icon": "icon.png",
|
||||
"type": "app",
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
(function(back) {
|
||||
var settings = require("Storage").readJSON("bthome.json",1)||{};
|
||||
if (!(settings.buttons instanceof Array))
|
||||
settings.buttons = [];
|
||||
var settings;
|
||||
|
||||
function loadSettings() {
|
||||
settings = require("Storage").readJSON("bthome.json",1)||{};
|
||||
if (!(settings.buttons instanceof Array))
|
||||
settings.buttons = [];
|
||||
}
|
||||
|
||||
function saveSettings() {
|
||||
require("Storage").writeJSON("bthome.json",settings)
|
||||
|
@ -15,7 +19,10 @@
|
|||
}
|
||||
var actions = ["press","double_press","triple_press","long_press","long_double_press","long_triple_press"];
|
||||
var menu = {
|
||||
"":{title:isNew ? /*LANG*/"New Button" : /*LANG*/"Edit Button", back:showMenu},
|
||||
"":{title:isNew ? /*LANG*/"New Button" : /*LANG*/"Edit Button", back: () => {
|
||||
loadSettings(); // revert changes
|
||||
showMenu();
|
||||
}},
|
||||
/*LANG*/"Icon" : {
|
||||
value : "\0"+require("icons").getIcon(button.icon),
|
||||
onchange : () => {
|
||||
|
@ -49,7 +56,7 @@
|
|||
onchange : v => button.n=v
|
||||
},
|
||||
/*LANG*/"Save" : () => {
|
||||
settings.buttons.push(button);
|
||||
if (isNew) settings.buttons.push(button);
|
||||
saveSettings();
|
||||
showMenu();
|
||||
}
|
||||
|
@ -94,5 +101,7 @@
|
|||
});
|
||||
E.showMenu(menu);
|
||||
}
|
||||
|
||||
loadSettings();
|
||||
showMenu();
|
||||
})
|
Loading…
Reference in New Issue