wallet listing working
This commit is contained in:
parent
bbd762a1fe
commit
6efa4f86de
14 changed files with 538 additions and 240 deletions
|
|
@ -1,10 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('HomeController',
|
||||
function($scope, $rootScope, $location, walletFactory, notification, controllerUtils) {
|
||||
|
||||
controllerUtils.redirIfLogged();
|
||||
angular.module('copayApp.controllers').controller('HomeController', function($scope, $rootScope, $location, walletFactory, notification, controllerUtils) {
|
||||
|
||||
controllerUtils.redirIfLogged();
|
||||
|
||||
$scope.loading = true;
|
||||
|
||||
walletFactory.getWallets(function(ret) {
|
||||
$scope.loading = false;
|
||||
$scope.hasWallets = (walletFactory.getWallets() && walletFactory.getWallets().length > 0) ? true : false;
|
||||
$scope.hasWallets = (ret && ret.length > 0) ? true : false;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,12 +14,18 @@ angular.module('copayApp.controllers').controller('OpenController', function($sc
|
|||
};
|
||||
$rootScope.fromSetup = false;
|
||||
$scope.loading = false;
|
||||
$scope.wallets = walletFactory.getWallets().sort(cmp);
|
||||
$scope.selectedWalletId = walletFactory.storage.getLastOpened() || ($scope.wallets[0] && $scope.wallets[0].id);
|
||||
walletFactory.getWallets(function(wallets) {
|
||||
$scope.wallets = wallets.sort(cmp);
|
||||
});
|
||||
|
||||
walletFactory.storage.getLastOpened(function(ret) {
|
||||
$scope.selectedWalletId = ret || ($scope.wallets[0] && $scope.wallets[0].id);
|
||||
});
|
||||
|
||||
$scope.openPassword = '';
|
||||
$scope.isMobile = !!window.cordova;
|
||||
|
||||
if (!$scope.wallets.length){
|
||||
if (!$scope.wallets.length) {
|
||||
$location.path('/');
|
||||
}
|
||||
|
||||
|
|
@ -34,19 +40,15 @@ angular.module('copayApp.controllers').controller('OpenController', function($sc
|
|||
|
||||
Passphrase.getBase64Async(password, function(passphrase) {
|
||||
var w, errMsg;
|
||||
try {
|
||||
w = walletFactory.open($scope.selectedWalletId, passphrase);
|
||||
} catch (e) {
|
||||
errMsg = e.message;
|
||||
};
|
||||
if (!w) {
|
||||
$scope.loading = false;
|
||||
notification.error('Error', errMsg || 'Wrong password');
|
||||
$rootScope.$digest();
|
||||
return;
|
||||
}
|
||||
$rootScope.updatingBalance = true;
|
||||
controllerUtils.startNetwork(w, $scope);
|
||||
walletFactory.open($scope.selectedWalletId, passphrase, function(err, w) {
|
||||
if (!w) {
|
||||
$scope.loading = false;
|
||||
notification.error('Error', err.errMsg || 'Wrong password');
|
||||
$rootScope.$digest();
|
||||
}
|
||||
$rootScope.updatingBalance = true;
|
||||
controllerUtils.startNetwork(w, $scope);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue