various fixes
This commit is contained in:
parent
23dc09a635
commit
19d1bde546
6 changed files with 19 additions and 19 deletions
|
|
@ -151,6 +151,7 @@ Identity.prototype.readAndBindWallet = function(walletId, cb) {
|
|||
var self = this;
|
||||
self.retrieveWalletFromStorage(walletId, {}, function(error, wallet) {
|
||||
if (!error) {
|
||||
self.wallets[wallet.getId()] = wallet;
|
||||
self.bindWallet(wallet);
|
||||
}
|
||||
return cb(error);
|
||||
|
|
@ -386,6 +387,8 @@ Identity.prototype.importWalletFromObj = function(obj, opts, cb) {
|
|||
log.debug('Updating Indexes for wallet:' + w.getName());
|
||||
w.updateIndexes(function(err) {
|
||||
log.debug('Adding wallet to profile:' + w.getName());
|
||||
self.wallets[w.getId()] = w;
|
||||
self.updateFocusedTimestamp(w.getId());
|
||||
self.bindWallet(w);
|
||||
self.storeWallet(w, cb);
|
||||
});
|
||||
|
|
@ -472,7 +475,6 @@ Identity.importFromFullJson = function(str, password, opts, cb) {
|
|||
*/
|
||||
Identity.prototype.bindWallet = function(w) {
|
||||
var self = this;
|
||||
self.wallets[w.getId()] = w;
|
||||
log.debug('Binding wallet:' + w.getName());
|
||||
|
||||
w.on('txProposalsUpdated', function() {
|
||||
|
|
@ -572,8 +574,9 @@ Identity.prototype.createWallet = function(opts, cb) {
|
|||
|
||||
|
||||
var w = new walletClass(opts);
|
||||
self.bindWallet(w);
|
||||
self.wallets[w.getId()] = w;
|
||||
self.updateFocusedTimestamp(w.getId());
|
||||
self.bindWallet(w);
|
||||
self.storeWallet(w, function(err) {
|
||||
if (err) return cb(err);
|
||||
|
||||
|
|
@ -664,15 +667,16 @@ Identity.prototype.decodeSecret = function(secret) {
|
|||
* @return {string} walletId
|
||||
*/
|
||||
Identity.prototype.getLastFocusedWalletId = function() {
|
||||
var max = _.max(this.focusedTimestamp);
|
||||
var aId = _.findKey(this.wallets) || this.walletIds[0];
|
||||
if (this.walletIds.length == 0) return undefined;
|
||||
|
||||
var max = _.max(this.focusedTimestamps);
|
||||
|
||||
if (!max)
|
||||
return aId;
|
||||
return this.walletIds[0];
|
||||
|
||||
return _.findKey(this.focusedTimestamps, function(ts) {
|
||||
return ts == max;
|
||||
}) || aId;
|
||||
}) || this.walletIds[0];
|
||||
};
|
||||
|
||||
Identity.prototype.updateFocusedTimestamp = function(wid) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue