Cleaning controllers. Also call connect socket-ii in all pages. Everything work!
This commit is contained in:
parent
5d83d180da
commit
8ab479691d
6 changed files with 68 additions and 46 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.controllerUtils').factory('controllerUtils', function ($rootScope, $location) {
|
||||
angular.module('copay.controllerUtils').factory('controllerUtils', function ($rootScope, $location, Socket) {
|
||||
var root = {};
|
||||
root.setupUxHandlers = function(w) {
|
||||
w.on('created', function() {
|
||||
|
|
@ -24,6 +24,26 @@ angular.module('copay.controllerUtils').factory('controllerUtils', function ($ro
|
|||
});
|
||||
};
|
||||
|
||||
root.handleTransactionByAddress = function(scope) {
|
||||
var socket = Socket(scope);
|
||||
var addrs = $rootScope.wallet.getAddressesStr();
|
||||
socket.emit('subscribe', 'inv');
|
||||
for(var i=0;i<addrs.length;i++) {
|
||||
socket.emit('subscribe', addrs[i]);
|
||||
}
|
||||
addrs.forEach(function(addr) {
|
||||
socket.on(addr, function(txid) {
|
||||
console.log('Received!', txid);
|
||||
$rootScope.wallet.getBalance(function(balance) {
|
||||
scope.$apply(function() {
|
||||
$rootScope.totalBalance = balance;
|
||||
});
|
||||
console.log('New balance:', balance);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue