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) {
|
var setPendingTxps = function(txps) {
|
||||||
$scope.txps = lodash.sort(txps, function(x) {
|
if (!txps) {
|
||||||
return walletId;
|
$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;
|
return x.walletId != wallet.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$log.debug('Updating wallet:'+ wallet.name)
|
||||||
walletService.getStatus(wallet, {}, function(err, status) {
|
walletService.getStatus(wallet, {}, function(err, status) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||||
return;
|
return;
|
||||||
} // TODO
|
}
|
||||||
if (status.pendingTxps && status.pendingTxps[0]) {
|
if (status.pendingTxps && status.pendingTxps[0]) {
|
||||||
txps = txps.concat(status.pendingTxps);
|
txps = txps.concat(status.pendingTxps);
|
||||||
txps = formatPendingTxps(txps);
|
txps = formatPendingTxps(txps);
|
||||||
|
|
@ -120,8 +125,14 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
self.updateAllWallets();
|
self.updateAllWallets();
|
||||||
$scope.bitpayCardEnabled = true; // TODO
|
$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;
|
var config = configService.getSync().wallet;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,37 +70,13 @@ angular.module('copayApp.services')
|
||||||
notificationService.newBWCNotification(n,
|
notificationService.newBWCNotification(n,
|
||||||
walletId, wallet.credentials.walletName);
|
walletId, wallet.credentials.walletName);
|
||||||
|
|
||||||
$rootScope.$emit(n.type, n, wallet);
|
$rootScope.$emit('bwsEvent', wallet.id, n.type, n);
|
||||||
// ))
|
|
||||||
// walletService allet.getStatus()
|
if (wallet.cacheStatus)
|
||||||
// wallet.getTxHistory()
|
wallet.cacheStatus.isValid = false;
|
||||||
//
|
|
||||||
// // update wallet?
|
if (wallet.completeHistory)
|
||||||
// if (lodash.indexOf( [,'NewOutgoingTx','NewOutgoingTxByThirdParty','NewTxProposal', 'TxProposalFinallyRejected', 'TxProposalRemoved'], n.type)>=0) {
|
wallet.completeHistory.isValid = false;
|
||||||
//
|
|
||||||
// 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,
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// //
|
|
||||||
//
|
|
||||||
});
|
});
|
||||||
|
|
||||||
wallet.on('walletCompleted', function() {
|
wallet.on('walletCompleted', function() {
|
||||||
|
|
@ -122,6 +98,10 @@ angular.module('copayApp.services')
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wallet.setNotificationsInterval(UPDATE_PERIOD);
|
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