mirror of https://github.com/BTCPrivate/copay.git
Rebased
This commit is contained in:
parent
12adaa64d2
commit
ce976a1b42
|
@ -14,15 +14,32 @@ 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);
|
||||
$scope.retreiving = true;
|
||||
|
||||
walletFactory.getWallets(function(err, wallets) {
|
||||
|
||||
if (err || !wallets || !wallets.length) {
|
||||
$location.path('/');
|
||||
} else {
|
||||
$scope.retreiving = false;
|
||||
$scope.wallets = wallets.sort(cmp);
|
||||
|
||||
walletFactory.storage.getLastOpened(function(ret) {
|
||||
if (ret && _.indexOf(_.pluck($scope.wallets, 'id')) == -1)
|
||||
ret = null;
|
||||
|
||||
$scope.selectedWalletId = ret || ($scope.wallets[0] && $scope.wallets[0].id);
|
||||
|
||||
setTimeout(function() {
|
||||
$rootScope.$digest();
|
||||
}, 0);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$scope.openPassword = '';
|
||||
$scope.isMobile = !!window.cordova;
|
||||
|
||||
if (!$scope.wallets.length) {
|
||||
$location.path('/');
|
||||
}
|
||||
|
||||
$scope.open = function(form) {
|
||||
if (form && form.$invalid) {
|
||||
notification.error('Error', 'Please enter the required fields');
|
||||
|
@ -34,19 +51,16 @@ 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;
|
||||
};
|
||||
walletFactory.open($scope.selectedWalletId, passphrase, function(err, w) {
|
||||
if (!w) {
|
||||
$scope.loading = false;
|
||||
notification.error('Error', errMsg || 'Wrong password');
|
||||
notification.error('Error', err.errMsg || 'Wrong password');
|
||||
$rootScope.$digest();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$rootScope.updatingBalance = true;
|
||||
controllerUtils.startNetwork(w, $scope);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue