Merge pull request #4295 from matiu/bug/angular-twice

Bug/angular twice
This commit is contained in:
Gustavo Maximiliano Cortez 2016-06-08 10:46:31 -03:00
commit 5558e91387
10 changed files with 100 additions and 51 deletions

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('importController',
function($scope, $rootScope, $ionicScrollDelegate, $timeout, $log, profileService, configService, notification, go, sjcl, gettext, lodash, ledger, trezor, derivationPathHelper, platformInfo) {
function($scope, $rootScope, $ionicScrollDelegate, $timeout, $log, profileService, configService, notification, go, sjcl, gettext, lodash, ledger, trezor, derivationPathHelper, platformInfo, bwsError, bwcService) {
var isChromeApp = platformInfo.isChromeApp;
var isDevel = platformInfo.isDevel;
@ -9,9 +9,11 @@ angular.module('copayApp.controllers').controller('importController',
var self = this;
var reader = new FileReader();
var defaults = configService.getDefaults();
var errors = bwcService.getErrors();
$scope.bwsurl = defaults.bws.url;
$scope.derivationPath = derivationPathHelper.default;
$scope.account = 1;
self.importErr = false;
window.ignoreMobilePause = true;
$scope.$on('$destroy', function() {
@ -20,6 +22,7 @@ angular.module('copayApp.controllers').controller('importController',
}, 100);
});
var updateSeedSourceSelect = function() {
self.seedOptions = [];
@ -52,7 +55,7 @@ angular.module('copayApp.controllers').controller('importController',
try {
str2 = sjcl.decrypt(self.password, str);
} catch (e) {
err = gettext('Could not decrypt file, check your spending password');
err = gettext('Could not decrypt file, check your password');
$log.warn(e);
};
@ -91,12 +94,17 @@ angular.module('copayApp.controllers').controller('importController',
profileService.importExtendedPrivateKey(xPrivKey, opts, function(err, walletId) {
self.loading = false;
if (err) {
self.error = err;
if (err instanceof errors.NOT_AUTHORIZED) {
self.importErr = true;
} else {
self.error = err;
}
$ionicScrollDelegate.scrollTop();
return $timeout(function() {
$scope.$apply();
});
}
$rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
@ -110,13 +118,19 @@ angular.module('copayApp.controllers').controller('importController',
$timeout(function() {
profileService.importMnemonic(words, opts, function(err, walletId) {
self.loading = false;
if (err) {
self.error = err;
if (err instanceof errors.NOT_AUTHORIZED) {
self.importErr = true;
} else {
self.error = err;
}
$ionicScrollDelegate.scrollTop();
return $timeout(function() {
$scope.$apply();
});
}
$rootScope.$emit('Local/WalletImported', walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome();
@ -265,6 +279,7 @@ angular.module('copayApp.controllers').controller('importController',
return;
}
this.error = '';
this.importErr = false;
var account = +$scope.account;

View file

@ -301,6 +301,7 @@ angular.module('copayApp.services')
var name = opts.name || gettextCatalog.getString('Personal Wallet');
var myName = opts.myName || gettextCatalog.getString('me');
console.log('[profileService.js.303]', opts); //TODO
walletClient.createWallet(name, myName, opts.m, opts.n, {
network: opts.networkName,
singleAddress: opts.singleAddress,
@ -543,8 +544,12 @@ angular.module('copayApp.services')
$log.debug('Importing Wallet xPrivKey');
walletClient.importFromExtendedPrivateKey(xPrivKey, opts, function(err) {
if (err)
if (err) {
if (err instanceof errors.NOT_AUTHORIZED)
return cb(err);
return bwsError.cb(err, gettext('Could not import'), cb);
}
root.addAndBindWalletClient(walletClient, {
bwsurl: opts.bwsurl,
@ -571,8 +576,12 @@ angular.module('copayApp.services')
passphrase: opts.passphrase,
account: opts.account || 0,
}, function(err) {
if (err)
if (err) {
if (err instanceof errors.NOT_AUTHORIZED)
return cb(err);
return bwsError.cb(err, gettext('Could not import'), cb);
}
root.addAndBindWalletClient(walletClient, {
bwsurl: opts.bwsurl,