Merge pull request #5080 from ajp8164/bug/local-storage-value-to-string
Detect and convert localStorage values to string.
This commit is contained in:
commit
6032347e3c
1 changed files with 9 additions and 1 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.services')
|
angular.module('copayApp.services')
|
||||||
.factory('localStorageService', function(platformInfo, $timeout, $log) {
|
.factory('localStorageService', function(platformInfo, $timeout, $log, lodash) {
|
||||||
var isNW = platformInfo.isNW;
|
var isNW = platformInfo.isNW;
|
||||||
var isChromeApp = platformInfo.isChromeApp;
|
var isChromeApp = platformInfo.isChromeApp;
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
@ -45,6 +45,14 @@ angular.module('copayApp.services')
|
||||||
root.set = function(k, v, cb) {
|
root.set = function(k, v, cb) {
|
||||||
if (isChromeApp || isNW) {
|
if (isChromeApp || isNW) {
|
||||||
var obj = {};
|
var obj = {};
|
||||||
|
|
||||||
|
if (lodash.isObject(v)) {
|
||||||
|
v = JSON.stringify(v);
|
||||||
|
}
|
||||||
|
if (!lodash.isString(v)) {
|
||||||
|
v = v.toString();
|
||||||
|
}
|
||||||
|
|
||||||
obj[k] = v;
|
obj[k] = v;
|
||||||
|
|
||||||
chrome.storage.local.set(obj, cb);
|
chrome.storage.local.set(obj, cb);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue