chromeStorage fixes
This commit is contained in:
parent
ee025fc80b
commit
5bfbf64778
7 changed files with 44 additions and 143 deletions
|
|
@ -1,17 +1,26 @@
|
|||
'use strict';
|
||||
angular.module('copayApp.services')
|
||||
.factory('applicationService', function() {
|
||||
var root = {};
|
||||
var root = {};
|
||||
var isChromeApp = window.chrome && chrome.runtime && chrome.runtime.id;
|
||||
|
||||
root.restart = function() {
|
||||
// Go home reloading the application
|
||||
var hashIndex = window.location.href.indexOf('#!/');
|
||||
root.restart = function() {
|
||||
|
||||
console.log('RESTART');
|
||||
|
||||
// Go home reloading the application
|
||||
var hashIndex = window.location.href.indexOf('#!/');
|
||||
if (isChromeApp) {
|
||||
console.log('isChromeApp restting ');
|
||||
chrome.runtime.restart();
|
||||
} else {
|
||||
window.location = window.location.href.substr(0, hashIndex);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
root.reload = function() {
|
||||
window.location.reload();
|
||||
};
|
||||
root.reload = function() {
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
return root;
|
||||
return root;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue