Merge pull request #77 from matiu/bug/fix-uxrefresh

fix uxrefresh with new #setup - awesome!!
This commit is contained in:
Gustavo Maximiliano Cortez 2014-04-17 11:49:02 -03:00
commit 73d5266a89
8 changed files with 46 additions and 46 deletions

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copay.setup').controller('SetupController',
function($scope, $rootScope, $location, walletFactory) {
function($scope, $rootScope, $location, walletFactory, controllerUtils) {
$scope.loading = false;
@ -32,16 +32,7 @@ angular.module('copay.setup').controller('SetupController',
totalCopayers: totalCopayers
};
var w = walletFactory.create(opts);
w.on('created', function(){
$location.path('peer');
$rootScope.wallet = w;
$rootScope.$digest();
});
w.on('openError', function(){
$scope.loading = false;
$rootScope.flashMessage = {type:'error', message: 'Wallet not found'};
$location.path('signin');
});
controllerUtils.setupUxHandlers(w);
w.netStart();
};

View file

@ -1,7 +1,9 @@
'use strict';
angular.module('copay.signin').controller('SigninController',
function($scope, $rootScope, $location, walletFactory) {
function($scope, $rootScope, $location, walletFactory, controllerUtils) {
// var peerData = Storage.get($rootScope.walletId, 'peerData');
// $rootScope.peerId = peerData ? peerData.peerId : null;
@ -13,25 +15,6 @@ angular.module('copay.signin').controller('SigninController',
return walletFactory.getWalletIds();
};
var _setupUxHandlers = function(w) {
w.on('created', function() {
$location.path('peer');
$rootScope.wallet = w;
$rootScope.$digest();
});
w.on('refresh', function() {
console.log('[signin.js.23] RECEIVED REFRESH'); //TODO
$rootScope.$digest();
});
w.on('openError', function(){
$scope.loading = false;
$rootScope.flashMessage = {type:'error', message: 'Wallet not found'};
$location.path('signin');
});
};
$scope.create = function() {
$location.path('setup');
};
@ -40,7 +23,7 @@ console.log('[signin.js.23] RECEIVED REFRESH'); //TODO
$scope.loading = true;
var w = walletFactory.open(walletId);
_setupUxHandlers(w);
controllerUtils.setupUxHandlers(w);
w.netStart();
};
@ -49,7 +32,7 @@ console.log('[signin.js.42:join:]'); //TODO
$scope.loading = true;
walletFactory.connectTo(cid, function(w) {
console.log('[signin.js.50]'); //TODO
_setupUxHandlers(w);
controllerUtils.setupUxHandlers(w);
w.netStart();
});
};