Rebased
This commit is contained in:
parent
12adaa64d2
commit
ce976a1b42
1 changed files with 33 additions and 19 deletions
|
|
@ -14,15 +14,32 @@ angular.module('copayApp.controllers').controller('OpenController', function($sc
|
||||||
};
|
};
|
||||||
$rootScope.fromSetup = false;
|
$rootScope.fromSetup = false;
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
$scope.wallets = walletFactory.getWallets().sort(cmp);
|
$scope.retreiving = true;
|
||||||
$scope.selectedWalletId = walletFactory.storage.getLastOpened() || ($scope.wallets[0] && $scope.wallets[0].id);
|
|
||||||
|
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.openPassword = '';
|
||||||
$scope.isMobile = !!window.cordova;
|
$scope.isMobile = !!window.cordova;
|
||||||
|
|
||||||
if (!$scope.wallets.length) {
|
|
||||||
$location.path('/');
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.open = function(form) {
|
$scope.open = function(form) {
|
||||||
if (form && form.$invalid) {
|
if (form && form.$invalid) {
|
||||||
notification.error('Error', 'Please enter the required fields');
|
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) {
|
Passphrase.getBase64Async(password, function(passphrase) {
|
||||||
var w, errMsg;
|
var w, errMsg;
|
||||||
try {
|
walletFactory.open($scope.selectedWalletId, passphrase, function(err, w) {
|
||||||
w = walletFactory.open($scope.selectedWalletId, passphrase);
|
if (!w) {
|
||||||
} catch (e) {
|
$scope.loading = false;
|
||||||
errMsg = e.message;
|
notification.error('Error', err.errMsg || 'Wrong password');
|
||||||
};
|
$rootScope.$digest();
|
||||||
if (!w) {
|
} else {
|
||||||
$scope.loading = false;
|
$rootScope.updatingBalance = true;
|
||||||
notification.error('Error', errMsg || 'Wrong password');
|
controllerUtils.startNetwork(w, $scope);
|
||||||
$rootScope.$digest();
|
}
|
||||||
return;
|
});
|
||||||
}
|
|
||||||
$rootScope.updatingBalance = true;
|
|
||||||
controllerUtils.startNetwork(w, $scope);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue