migration to platformInfo WIP
Conflicts: src/js/controllers/buyGlidera.js src/js/controllers/walletHome.js src/js/services/localStorage.js
This commit is contained in:
parent
36cf4f0560
commit
dd1981a26c
23 changed files with 108 additions and 66 deletions
|
|
@ -1,20 +1,21 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services')
|
||||
.factory('localStorageService', function(isChromeApp, nodeWebkit, $timeout) {
|
||||
.factory('localStorageService', function(platformInfo, $timeout) {
|
||||
var isNW = platformInfo.isNW;
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
var root = {};
|
||||
var ls = ((typeof window.localStorage !== "undefined") ? window.localStorage : null);
|
||||
|
||||
if (isChromeApp && !nodeWebkit.isDefined() && !ls) {
|
||||
ls = localStorage = chrome.storage.local;
|
||||
window.localStorage = chrome.storage.local;
|
||||
if (isChromeApp && !isNW && !ls) {
|
||||
ls = chrome.storage.local;
|
||||
}
|
||||
|
||||
if (!ls)
|
||||
throw new Error('localstorage not available');
|
||||
|
||||
root.get = function(k, cb) {
|
||||
if (isChromeApp && !nodeWebkit.isDefined()) {
|
||||
if (isChromeApp && !isNW) {
|
||||
chrome.storage.local.get(k,
|
||||
function(data) {
|
||||
//TODO check for errors
|
||||
|
|
@ -40,7 +41,7 @@ angular.module('copayApp.services')
|
|||
};
|
||||
|
||||
root.set = function(k, v, cb) {
|
||||
if (isChromeApp && !nodeWebkit.isDefined()) {
|
||||
if (isChromeApp && !isNW) {
|
||||
var obj = {};
|
||||
obj[k] = v;
|
||||
|
||||
|
|
@ -53,7 +54,7 @@ angular.module('copayApp.services')
|
|||
};
|
||||
|
||||
root.remove = function(k, cb) {
|
||||
if (isChromeApp && !nodeWebkit.isDefined()) {
|
||||
if (isChromeApp && !isNW) {
|
||||
chrome.storage.local.remove(k, cb);
|
||||
} else {
|
||||
ls.removeItem(k);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue