You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@milagro.apache.org by br...@apache.org on 2018/11/08 00:42:27 UTC
[incubator-milagro-javascript] 13/19: Add initial initialisation of
the local storage This prevent some problems when trying to access it and
the info is not avaible
This is an automated email from the ASF dual-hosted git repository.
brianspector pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-milagro-javascript.git
commit 06e0c9eb61b8f4a4298aa99821befe68e12dadba
Author: Pavlin Angelov <pa...@miracl.com>
AuthorDate: Mon Nov 7 10:38:05 2016 +0200
Add initial initialisation of the local storage
This prevent some problems when trying to access it and the info is not
avaible
---
lib/mpin.js | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/lib/mpin.js b/lib/mpin.js
index 12901c3..c3d7e89 100644
--- a/lib/mpin.js
+++ b/lib/mpin.js
@@ -6,9 +6,9 @@
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -65,6 +65,16 @@ var mpinjs = (function () {
var self = this, _initUrl;
this.recover();
+
+ var mpinData = this.getData();
+ if (!mpinData) {
+ mpinData = {
+ version: "4",
+ accounts: {}
+ };
+ this.storeData(mpinData);
+ }
+
if (this.opts.server.slice(-1) === "/") {
_initUrl = this.opts.server;
} else {
@@ -889,15 +899,7 @@ var mpinjs = (function () {
Mpin.prototype.setData = function (userId, upData) {
var mpinData = this.getData();
- if (!mpinData) {
- mpinData = {
- version: "4",
- accounts: {}
- };
- }
-
var mpinId = upData.mpinId || Users[userId].mpinId;
-
if (!mpinId) {
return false;
}