various fixes

This commit is contained in:
Ivan Socolsky 2014-12-02 14:33:46 -03:00 committed by Matias Alejo Garcia
commit 19d1bde546
6 changed files with 19 additions and 19 deletions

View file

@ -62,7 +62,8 @@ angular.module('copayApp.controllers').controller('CreateController',
$scope.error = 'Could not create wallet: ' + err;
}
}
$rootScope.$digest()
$rootScope.$digest();
});
};
});

View file

@ -1,5 +0,0 @@
'use strict';
angular.module('copayApp.controllers').controller('CreateWalletController', function($scope, $rootScope) {
$rootScope.title = 'Create Wallet';
});

View file

@ -18,14 +18,14 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
$scope.done = function() {
$rootScope.starting = false;
setTimeout(function () { $rootScope.$digest(); }, 1);
$rootScope.$digest();
};
$scope.$on("$destroy", function(){
var iden = $rootScope.iden;
if (iden) {
iden.removeListener('newWallets', $scope.done );
iden.removeListener('newWallet', $scope.done );
iden.removeListener('noWallets', $scope.done );
}
});

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('HomeWalletController',
function($scope, $rootScope) {
angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope) {
$scope.init = function() {
$rootScope.title = 'Home';
$scope.addr = _.last($rootScope.wallet.getReceiveAddresses());
@ -9,5 +9,5 @@ angular.module('copayApp.controllers').controller('HomeWalletController',
$rootScope.$watch('wallet', function() {
$scope.addr = _.last($rootScope.wallet.getReceiveAddresses());
});
}
);
};
});

View file

@ -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) {

View file

@ -1,4 +1,4 @@
<div class="home-wallet" ng-controller="HomeWalletController">
<div class="home-wallet" ng-controller="HomeWalletController" ng-init="init()">
<div class="row hide-for-large-up">
<div class="medium-12 small-12 columns">
<h1 translate>Home</h1>