Merge pull request #5080 from ajp8164/bug/local-storage-value-to-string

Detect and convert localStorage values to string.
This commit is contained in:
Jason Dreyzehner 2016-11-17 18:58:06 -05:00 committed by GitHub
commit 6032347e3c
1 changed files with 9 additions and 1 deletions

View File

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.services')
.factory('localStorageService', function(platformInfo, $timeout, $log) {
.factory('localStorageService', function(platformInfo, $timeout, $log, lodash) {
var isNW = platformInfo.isNW;
var isChromeApp = platformInfo.isChromeApp;
var root = {};
@ -45,6 +45,14 @@ angular.module('copayApp.services')
root.set = function(k, v, cb) {
if (isChromeApp || isNW) {
var obj = {};
if (lodash.isObject(v)) {
v = JSON.stringify(v);
}
if (!lodash.isString(v)) {
v = v.toString();
}
obj[k] = v;
chrome.storage.local.set(obj, cb);