wallet updates on events!
This commit is contained in:
parent
240e26a783
commit
db0cdec49e
2 changed files with 26 additions and 35 deletions
|
|
@ -8,8 +8,12 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
|
||||
|
||||
var setPendingTxps = function(txps) {
|
||||
$scope.txps = lodash.sort(txps, function(x) {
|
||||
return walletId;
|
||||
if (!txps) {
|
||||
$scope.txps = [];
|
||||
return;
|
||||
}
|
||||
$scope.txps = txps.sort(function(a, b) {
|
||||
return a.walletId.localeCompare(b.walletId);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -101,11 +105,12 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
return x.walletId != wallet.id;
|
||||
});
|
||||
|
||||
$log.debug('Updating wallet:'+ wallet.name)
|
||||
walletService.getStatus(wallet, {}, function(err, status) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
return;
|
||||
} // TODO
|
||||
}
|
||||
if (status.pendingTxps && status.pendingTxps[0]) {
|
||||
txps = txps.concat(status.pendingTxps);
|
||||
txps = formatPendingTxps(txps);
|
||||
|
|
@ -120,8 +125,14 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
self.updateAllWallets();
|
||||
$scope.bitpayCardEnabled = true; // TODO
|
||||
|
||||
var c1 = $rootScope.$on('bwsEvent', function(e, walletId, type, n) {
|
||||
var wallet = profileService.getWallet(walletId);
|
||||
self.updateWallet(wallet);
|
||||
});
|
||||
|
||||
$scope.$on('$destroy', function() {});
|
||||
$scope.$on('$destroy', function() {
|
||||
c1();
|
||||
});
|
||||
|
||||
var config = configService.getSync().wallet;
|
||||
|
||||
|
|
|
|||
|
|
@ -70,37 +70,13 @@ angular.module('copayApp.services')
|
|||
notificationService.newBWCNotification(n,
|
||||
walletId, wallet.credentials.walletName);
|
||||
|
||||
$rootScope.$emit(n.type, n, wallet);
|
||||
// ))
|
||||
// walletService allet.getStatus()
|
||||
// wallet.getTxHistory()
|
||||
//
|
||||
// // update wallet?
|
||||
// if (lodash.indexOf( [,'NewOutgoingTx','NewOutgoingTxByThirdParty','NewTxProposal', 'TxProposalFinallyRejected', 'TxProposalRemoved'], n.type)>=0) {
|
||||
//
|
||||
// wallet.update
|
||||
//
|
||||
// };
|
||||
//
|
||||
// 'NewBlock'
|
||||
// });
|
||||
//
|
||||
// //untilItChange FALSE
|
||||
// lodash.each(['NewTxProposal', , 'NewOutgoingTxByThirdParty',
|
||||
// 'Local/GlideraTx'
|
||||
// ], function(eventName) {
|
||||
// $rootScope.$on(eventName, function(event) {
|
||||
// self.updateAll({
|
||||
// walletStatus: null,
|
||||
// untilItChanges: null,
|
||||
// triggerTxUpdate: true,
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
//
|
||||
//
|
||||
// //
|
||||
//
|
||||
$rootScope.$emit('bwsEvent', wallet.id, n.type, n);
|
||||
|
||||
if (wallet.cacheStatus)
|
||||
wallet.cacheStatus.isValid = false;
|
||||
|
||||
if (wallet.completeHistory)
|
||||
wallet.completeHistory.isValid = false;
|
||||
});
|
||||
|
||||
wallet.on('walletCompleted', function() {
|
||||
|
|
@ -122,6 +98,10 @@ angular.module('copayApp.services')
|
|||
return;
|
||||
}
|
||||
wallet.setNotificationsInterval(UPDATE_PERIOD);
|
||||
wallet.openWallet(function(err) {
|
||||
if (wallet.status !== true)
|
||||
$log.log('Wallet + ' + walletId + ' status:' + wallet.status)
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue