chromeStorage fixes

This commit is contained in:
Matias Pando 2014-12-04 15:45:50 -03:00
commit 5bfbf64778
7 changed files with 44 additions and 143 deletions

View file

@ -1,32 +1,19 @@
'use strict';
var LS = require('../plugins/LocalStorage');
var ls = new LS();
angular.module('copayApp.services').
factory('notification', ['$timeout',
function($timeout) {
var localStorage;
if (window.chrome && chrome.runtime && chrome.runtime.id) {
console.log('Is a chrome app!...notification.js');
localStorage = chrome.storage.local;
} else {
console.log('Is web!');
localStorage = window.localStorage;
}
var notifications = [];
if (window.chrome && chrome.runtime && chrome.runtime.id) {
localStorage.get('notifications', function(data) {
console.log('data', data);
if (data) {
notifications = JSON.parse(data);
}
});
} else {
notifications = JSON.parse(localStorage.getItem('notifications')) || [];
}
ls.getItem('notifications', function(err, data) {
if (data) {
notifications = JSON.parse(data);
}
});
var queue = [];
var settings = {