refactory of the socket service
This commit is contained in:
parent
58a15502d1
commit
0455d5ee69
12 changed files with 94 additions and 137 deletions
|
|
@ -1,9 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.backup').controller('BackupController',
|
||||
function($scope, $rootScope, $location, $window, $timeout, Socket, controllerUtils) {
|
||||
controllerUtils.handleTransactionByAddress($scope);
|
||||
|
||||
function($scope, $rootScope, $location, $window, $timeout) {
|
||||
$scope.title = 'Backup';
|
||||
|
||||
var filename = $rootScope.wallet.id + '.json.aes';
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@ angular.module('copay.header').controller('HeaderController',
|
|||
'link': '#/backup'
|
||||
}];
|
||||
|
||||
$rootScope.$watch('wallet', function(wallet) {
|
||||
if (wallet) {
|
||||
controllerUtils.setSocketHandlers();
|
||||
}
|
||||
});
|
||||
|
||||
$scope.isActive = function(item) {
|
||||
if (item.link && item.link.replace('#','') == $location.path()) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.home').controller('HomeController',
|
||||
function($scope, $rootScope, $location, Socket, controllerUtils) {
|
||||
function($scope, $rootScope, controllerUtils) {
|
||||
$scope.title = 'Home';
|
||||
$scope.oneAtATime = true;
|
||||
$scope.addrBalance = {};
|
||||
|
|
@ -10,18 +10,19 @@ angular.module('copay.home').controller('HomeController',
|
|||
|
||||
var _updateBalance = function () {
|
||||
w.getBalance(function (balance, balanceByAddr) {
|
||||
$scope.balanceByAddr = balanceByAddr;
|
||||
$scope.addrs = Object.keys(balanceByAddr);
|
||||
$scope.selectedAddr = $scope.addrs[0];
|
||||
$scope.$digest();
|
||||
$rootScope.$apply(function() {
|
||||
$rootScope.balanceByAddr = balanceByAddr;
|
||||
$scope.addrs = Object.keys(balanceByAddr);
|
||||
$scope.selectedAddr = $scope.addrs[0];
|
||||
});
|
||||
});
|
||||
var socket = Socket($scope);
|
||||
controllerUtils.handleTransactionByAddress($scope, _updateBalance);
|
||||
};
|
||||
|
||||
$scope.newAddr = function() {
|
||||
var a = w.generateAddress().toString();
|
||||
w.generateAddress().toString();
|
||||
_updateBalance();
|
||||
|
||||
controllerUtils.setSocketHandlers();
|
||||
};
|
||||
|
||||
$scope.selectAddr = function(addr) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.peer').controller('PeerController',
|
||||
function($scope, $rootScope, $location, $routeParams, Socket, controllerUtils) {
|
||||
controllerUtils.handleTransactionByAddress($scope);
|
||||
function($scope, $rootScope, $location, $routeParams) {
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.send').controller('SendController',
|
||||
function($scope, $rootScope, $location, Socket, controllerUtils) {
|
||||
function($scope, $rootScope, $location) {
|
||||
$scope.title = 'Send';
|
||||
|
||||
controllerUtils.handleTransactionByAddress($scope);
|
||||
|
||||
$scope.sendTest = function() {
|
||||
var w = $rootScope.wallet;
|
||||
w.createTx( 'mimoZNLcP2rrMRgdeX5PSnR7AjCqQveZZ4', '12345',function() {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ angular.module('copay.setup').controller('SetupController',
|
|||
|
||||
$scope.$watch('totalCopayers', function(tc) {
|
||||
updateRCSelect(tc);
|
||||
})
|
||||
});
|
||||
|
||||
$scope.create = function(totalCopayers, requiredCopayers) {
|
||||
$scope.loading = true;
|
||||
|
|
|
|||
|
|
@ -2,15 +2,8 @@
|
|||
|
||||
angular.module('copay.signin').controller('SigninController',
|
||||
function($scope, $rootScope, $location, walletFactory, controllerUtils) {
|
||||
|
||||
// var peerData = Storage.get($rootScope.walletId, 'peerData');
|
||||
// $rootScope.peerId = peerData ? peerData.peerId : null;
|
||||
//
|
||||
|
||||
$scope.loading = false;
|
||||
|
||||
$scope.walletIds = walletFactory.getWalletIds();
|
||||
|
||||
$scope.selectedWalletId = $scope.walletIds.length ? $scope.walletIds[0]:null;
|
||||
|
||||
$scope.create = function() {
|
||||
|
|
@ -25,39 +18,15 @@ angular.module('copay.signin').controller('SigninController',
|
|||
w.netStart();
|
||||
};
|
||||
|
||||
$scope.join = function(cid) {
|
||||
$scope.join = function(peerId) {
|
||||
$scope.loading = true;
|
||||
walletFactory.network.on('openError', function() {
|
||||
controllerUtils.onError($scope);
|
||||
$rootScope.$digest();
|
||||
});
|
||||
walletFactory.connectTo(cid, function(w) {
|
||||
walletFactory.connectTo(peerId, function(w) {
|
||||
controllerUtils.setupUxHandlers(w);
|
||||
w.netStart();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// if (cid) {
|
||||
// var w = walletFactory.(walletId);
|
||||
//TODO
|
||||
// Network.init(null, function() {
|
||||
// Network.connect(cid,
|
||||
// function() {
|
||||
// $location.path('peer');
|
||||
// $rootScope.$digest();
|
||||
// }, function() {
|
||||
// $rootScope.flashMessage = { message: 'Connection refussed', type: 'error'};
|
||||
// $location.path('home');
|
||||
// $rootScope.$digest();
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
|
||||
// if (peerData && peerData.peerId && peerData.connectedPeers.length > 0) {
|
||||
// $rootScope.peerId = peerData.peerId;
|
||||
// $scope.join(peerData.connectedPeers);
|
||||
// }
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copay.transactions').controller('TransactionsController',
|
||||
function($scope, $rootScope, $location, Socket, controllerUtils) {
|
||||
function($scope, $rootScope, $location) {
|
||||
$scope.title = 'Transactions';
|
||||
|
||||
$scope.oneAtATime = true;
|
||||
|
|
@ -35,8 +35,6 @@ angular.module('copay.transactions').controller('TransactionsController',
|
|||
};
|
||||
|
||||
_updateTxs();
|
||||
var socket = Socket($scope);
|
||||
socket.on('connect', controllerUtils.handleTransactionByAddress($scope));
|
||||
|
||||
$scope.sign = function (ntxid) {
|
||||
var w = $rootScope.wallet;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue