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:
Matias Alejo Garcia 2016-05-31 14:55:08 -03:00
commit dd1981a26c
No known key found for this signature in database
GPG key ID: 02470DB551277AB3
23 changed files with 108 additions and 66 deletions

View file

@ -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);