Commit 5559a6a0 authored by Eric Seigne's avatar Eric Seigne
Browse files

fix js error on empty account list

parent add334af
......@@ -219,19 +219,19 @@ function addAccount(storageKey, email, apikey, server) {
return new Promise((resolve, reject) => {
let update = 0;
//On cherche une place de libre (max 4 on a dit)
let accounts = JSON.parse(localGetData(storageKey));
if (accounts === null) {
accounts = [];
let a = localGetData(storageKey);
let accounts = [];
if (a !== null && a !== "") {
accounts = JSON.parse(a);
}
else {
//evite les doublons, on update la clé
for (let f = 0; f < accounts.length; f++) {
if (accounts[f]['email'] == email) {
accounts[f]['apikey'] = apikey;
accounts[f]['server'] = server;
update = 1;
myDebug("addAccount : update");
}
//evite les doublons, on update la clé
for (let f = 0; f < accounts.length; f++) {
if (accounts[f]['email'] == email) {
accounts[f]['apikey'] = apikey;
accounts[f]['server'] = server;
update = 1;
myDebug("addAccount : update");
}
}
if (update == 0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment