mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #3338 from matiu/feat/bwc-111-notifications
feat/bwc-111-notifiactions
This commit is contained in:
commit
e5a9d6dcef
|
@ -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",
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue