Merge pull request #972 from andrewgoz/master

Fix JSON save format
pull/975/head^2
Gordon Williams 2021-11-30 17:14:26 +00:00 committed by GitHub
commit 3ddd169612
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 4 deletions

View File

@ -4433,7 +4433,7 @@
"shortName": "AuthWatch",
"icon": "app.png",
"screenshots": [{"url":"screenshot.png"}],
"version": "0.01",
"version": "0.02",
"description": "Google Authenticator compatible tool.",
"tags": "tool",
"interface": "interface.html",

View File

@ -1 +1,2 @@
0.02: Fix JSON save format
0.01: First release

View File

@ -8,6 +8,7 @@ const algos = {
};
var tokens = require("Storage").readJSON("authentiwatch.json", true) || [];
tokens = tokens.data;
// QR Code Text
//
@ -257,7 +258,8 @@ function onSwipe(e) {
}
if (e == -1 && state.curtoken != -1 && tokens[state.curtoken].period <= 0) {
tokens[state.curtoken].period--;
require("Storage").writeJSON("authentiwatch.json", tokens);
let save={data:tokens,count:tokens.length};
require("Storage").writeJSON("authentiwatch.json", save);
state.nextTime = 0;
state.hide = 2;
draw();

View File

@ -322,7 +322,8 @@ function loadTokens() {
Puck.eval(`require('Storage').read(${JSON.stringify('authentiwatch.json')})`,data=>{
Util.hideModal();
try {
tokens = JSON.parse(data);
let load = JSON.parse(data);
tokens = load.data;
updateTokens();
} catch {
tokens = [];
@ -333,7 +334,8 @@ function loadTokens() {
*/
function saveTokens() {
Util.showModal('Saving...');
Puck.write(`\x10require('Storage').write(${JSON.stringify('authentiwatch.json')},${JSON.stringify(tokens)})\n`,()=>{
let save={data:tokens,count:tokens.length};
Puck.write(`\x10require('Storage').write(${JSON.stringify('authentiwatch.json')},${JSON.stringify(save)})\n`,()=>{
Util.hideModal();
});
}