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": {
|
"dependencies": {
|
||||||
"angular": "1.4.6",
|
"angular": "1.4.6",
|
||||||
"angular-bitcore-wallet-client": "0.6.4",
|
"angular-bitcore-wallet-client": "1.1.1",
|
||||||
"angular-foundation": "0.7.0",
|
"angular-foundation": "0.7.0",
|
||||||
"angular-gettext": "2.1.0",
|
"angular-gettext": "2.1.0",
|
||||||
"angular-moment": "0.10.1",
|
"angular-moment": "0.10.1",
|
||||||
|
|
|
@ -4,6 +4,9 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
|
var FOREGROUND_UPDATE_PERIOD = 5;
|
||||||
|
var BACKGROUND_UPDATE_PERIOD = 30;
|
||||||
|
|
||||||
root.profile = null;
|
root.profile = null;
|
||||||
root.focusedClient = null;
|
root.focusedClient = null;
|
||||||
root.walletClients = {};
|
root.walletClients = {};
|
||||||
|
@ -37,6 +40,14 @@ angular.module('copayApp.services')
|
||||||
$rootScope.$emit('Local/NoWallets');
|
$rootScope.$emit('Local/NoWallets');
|
||||||
} else {
|
} else {
|
||||||
$rootScope.$emit('Local/NewFocusedWallet');
|
$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();
|
return cb();
|
||||||
|
@ -68,18 +79,6 @@ angular.module('copayApp.services')
|
||||||
root.walletClients[credentials.walletId] = client;
|
root.walletClients[credentials.walletId] = client;
|
||||||
client.removeAllListeners();
|
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) {
|
client.on('notification', function(n) {
|
||||||
$log.debug('BWC Notification:', n);
|
$log.debug('BWC Notification:', n);
|
||||||
notificationService.newBWCNotification(n,
|
notificationService.newBWCNotification(n,
|
||||||
|
@ -104,11 +103,12 @@ angular.module('copayApp.services')
|
||||||
root.walletClients[credentials.walletId].started = true;
|
root.walletClients[credentials.walletId].started = true;
|
||||||
root.walletClients[credentials.walletId].doNotVerifyPayPro = isChromeApp;
|
root.walletClients[credentials.walletId].doNotVerifyPayPro = isChromeApp;
|
||||||
|
|
||||||
client.initNotifications(function(err) {
|
client.initialize({}, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
$log.error('Could not init notifications err:', err);
|
$log.error('Could not init notifications err:', err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
client.setNotificationsInterval(BACKGROUND_UPDATE_PERIOD);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue