feat/bwc-111-notifiactions

This commit is contained in:
Matias Alejo Garcia 2015-10-23 12:16:41 -03:00
parent 597e9cec23
commit 6a49a505c4
2 changed files with 14 additions and 14 deletions

View File

@ -8,7 +8,7 @@
],
"dependencies": {
"angular": "1.4.6",
"angular-bitcore-wallet-client": "0.6.4",
"angular-bitcore-wallet-client": "1.1.1",
"angular-foundation": "0.7.0",
"angular-gettext": "2.1.0",
"angular-moment": "0.10.1",

View File

@ -4,6 +4,9 @@ angular.module('copayApp.services')
var root = {};
var FOREGROUND_UPDATE_PERIOD = 5;
var BACKGROUND_UPDATE_PERIOD = 30;
root.profile = null;
root.focusedClient = null;
root.walletClients = {};
@ -37,6 +40,14 @@ angular.module('copayApp.services')
$rootScope.$emit('Local/NoWallets');
} else {
$rootScope.$emit('Local/NewFocusedWallet');
// Set update period
lodash.each(root.walletClients, function(client, id) {
client.setNotificationsInterval(BACKGROUND_UPDATE_PERIOD);
});
root.focusedClient.setNotificationsInterval(FOREGROUND_UPDATE_PERIOD);
console.log('[profileService.js.49] SETTING...'); //TODO
}
return cb();
@ -68,18 +79,6 @@ angular.module('copayApp.services')
root.walletClients[credentials.walletId] = client;
client.removeAllListeners();
client.on('reconnect', function() {
if (root.focusedClient.credentials.walletId == client.credentials.walletId) {
$log.debug('### Online');
}
});
client.on('reconnecting', function() {
if (root.focusedClient.credentials.walletId == client.credentials.walletId) {
$log.debug('### Offline');
}
});
client.on('notification', function(n) {
$log.debug('BWC Notification:', n);
notificationService.newBWCNotification(n,
@ -104,11 +103,12 @@ angular.module('copayApp.services')
root.walletClients[credentials.walletId].started = true;
root.walletClients[credentials.walletId].doNotVerifyPayPro = isChromeApp;
client.initNotifications(function(err) {
client.initialize({}, function(err) {
if (err) {
$log.error('Could not init notifications err:', err);
return;
}
client.setNotificationsInterval(BACKGROUND_UPDATE_PERIOD);
});
}