handling profile with no wallets
This commit is contained in:
parent
0656c8d7e0
commit
fc0535a69f
2 changed files with 40 additions and 40 deletions
|
|
@ -519,6 +519,7 @@ Identity.prototype.decodeSecret = function(secret) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Identity.prototype.getLastFocusedWallet = function() {
|
Identity.prototype.getLastFocusedWallet = function() {
|
||||||
|
if (_.keys(this.wallets).length == 0) return;
|
||||||
return _.max(this.wallets, function(wallet) {
|
return _.max(this.wallets, function(wallet) {
|
||||||
return wallet.lastTimestamp || 0;
|
return wallet.lastTimestamp || 0;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,48 +1,47 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.services')
|
angular.module('copayApp.services')
|
||||||
.factory('identityService', function($rootScope, $location, pluginManager, controllerUtils) {
|
.factory('identityService', function($rootScope, $location, pluginManager, controllerUtils) {
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
root.create = function (scope, form) {
|
root.create = function(scope, form) {
|
||||||
copay.Identity.create({
|
copay.Identity.create({
|
||||||
email: form.email.$modelValue,
|
email: form.email.$modelValue,
|
||||||
password: form.password.$modelValue,
|
password: form.password.$modelValue,
|
||||||
pluginManager: pluginManager,
|
pluginManager: pluginManager,
|
||||||
network: config.network,
|
network: config.network,
|
||||||
networkName: config.networkName,
|
networkName: config.networkName,
|
||||||
walletDefaults: config.wallet,
|
walletDefaults: config.wallet,
|
||||||
passphraseConfig: config.passphraseConfig,
|
passphraseConfig: config.passphraseConfig,
|
||||||
}, function(err, iden) {
|
}, function(err, iden) {
|
||||||
var firstWallet = iden.getLastFocusedWallet();
|
|
||||||
controllerUtils.bindProfile(scope, iden, firstWallet);
|
|
||||||
scope.loading = false;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
root.open = function (scope, form) {
|
|
||||||
copay.Identity.open({
|
|
||||||
email: form.email.$modelValue,
|
|
||||||
password: form.password.$modelValue,
|
|
||||||
pluginManager: pluginManager,
|
|
||||||
network: config.network,
|
|
||||||
networkName: config.networkName,
|
|
||||||
walletDefaults: config.wallet,
|
|
||||||
passphraseConfig: config.passphraseConfig,
|
|
||||||
}, function(err, iden) {
|
|
||||||
if (err && !iden) {
|
|
||||||
console.log('Error:' + err)
|
|
||||||
controllerUtils.onErrorDigest(
|
|
||||||
scope, (err.toString() || '').match('PNOTFOUND') ? 'Profile not found' : 'Unknown error');
|
|
||||||
} else {
|
|
||||||
var firstWallet = iden.getLastFocusedWallet();
|
var firstWallet = iden.getLastFocusedWallet();
|
||||||
controllerUtils.bindProfile(scope, iden, firstWallet);
|
controllerUtils.bindProfile(scope, iden, firstWallet);
|
||||||
}
|
scope.loading = false;
|
||||||
scope.loading = false;
|
});
|
||||||
});
|
};
|
||||||
}
|
|
||||||
|
|
||||||
return root;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
root.open = function(scope, form) {
|
||||||
|
copay.Identity.open({
|
||||||
|
email: form.email.$modelValue,
|
||||||
|
password: form.password.$modelValue,
|
||||||
|
pluginManager: pluginManager,
|
||||||
|
network: config.network,
|
||||||
|
networkName: config.networkName,
|
||||||
|
walletDefaults: config.wallet,
|
||||||
|
passphraseConfig: config.passphraseConfig,
|
||||||
|
}, function(err, iden) {
|
||||||
|
if (err && !iden) {
|
||||||
|
console.log('Error:' + err)
|
||||||
|
controllerUtils.onErrorDigest(
|
||||||
|
scope, (err.toString() || '').match('PNOTFOUND') ? 'Profile not found' : 'Unknown error');
|
||||||
|
} else {
|
||||||
|
var firstWallet = iden.getLastFocusedWallet();
|
||||||
|
controllerUtils.bindProfile(scope, iden, firstWallet);
|
||||||
|
}
|
||||||
|
scope.loading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return root;
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue