mirror of https://github.com/BTCPrivate/copay.git
Refresh balance on new block
This commit is contained in:
parent
26c829f6de
commit
e1dc275ddd
|
@ -292,6 +292,15 @@ angular.module('copayApp.services')
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
if (!$rootScope.wallet.spendUnconfirmed && !Socket.isListeningBlocks()) {
|
||||
Socket.emit('subscribe', 'inv');
|
||||
Socket.on('block', function(block) {
|
||||
root.updateBalance(function() {
|
||||
$rootScope.$digest();
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
return root;
|
||||
});
|
||||
|
|
|
@ -38,6 +38,7 @@ angular.module('copayApp.services').factory('Socket',
|
|||
var ret = {};
|
||||
|
||||
var addrList = listeners
|
||||
.filter(function(i) { return i.event != 'block'; })
|
||||
.map(function(i) {return i.event;});
|
||||
|
||||
for (var i in addrList) {
|
||||
|
@ -45,6 +46,9 @@ angular.module('copayApp.services').factory('Socket',
|
|||
}
|
||||
return ret;
|
||||
},
|
||||
isListeningBlocks: function() {
|
||||
return listeners.filter(function(i) { return i.event == 'block'; }).length > 0;
|
||||
},
|
||||
emit: function(event, data, callback) {
|
||||
socket.emit(event, data, function() {
|
||||
var args = arguments;
|
||||
|
|
Loading…
Reference in New Issue