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; $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() { $scope.done = function() {
$rootScope.starting = false; $rootScope.starting = false;
setTimeout(function () { $rootScope.$digest(); }, 1); $rootScope.$digest();
}; };
$scope.$on("$destroy", function(){ $scope.$on("$destroy", function(){
var iden = $rootScope.iden; var iden = $rootScope.iden;
if (iden) { if (iden) {
iden.removeListener('newWallets', $scope.done ); iden.removeListener('newWallet', $scope.done );
iden.removeListener('noWallets', $scope.done ); iden.removeListener('noWallets', $scope.done );
} }
}); });

View file

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

View file

@ -151,6 +151,7 @@ Identity.prototype.readAndBindWallet = function(walletId, cb) {
var self = this; var self = this;
self.retrieveWalletFromStorage(walletId, {}, function(error, wallet) { self.retrieveWalletFromStorage(walletId, {}, function(error, wallet) {
if (!error) { if (!error) {
self.wallets[wallet.getId()] = wallet;
self.bindWallet(wallet); self.bindWallet(wallet);
} }
return cb(error); return cb(error);
@ -386,6 +387,8 @@ Identity.prototype.importWalletFromObj = function(obj, opts, cb) {
log.debug('Updating Indexes for wallet:' + w.getName()); log.debug('Updating Indexes for wallet:' + w.getName());
w.updateIndexes(function(err) { w.updateIndexes(function(err) {
log.debug('Adding wallet to profile:' + w.getName()); log.debug('Adding wallet to profile:' + w.getName());
self.wallets[w.getId()] = w;
self.updateFocusedTimestamp(w.getId());
self.bindWallet(w); self.bindWallet(w);
self.storeWallet(w, cb); self.storeWallet(w, cb);
}); });
@ -472,7 +475,6 @@ Identity.importFromFullJson = function(str, password, opts, cb) {
*/ */
Identity.prototype.bindWallet = function(w) { Identity.prototype.bindWallet = function(w) {
var self = this; var self = this;
self.wallets[w.getId()] = w;
log.debug('Binding wallet:' + w.getName()); log.debug('Binding wallet:' + w.getName());
w.on('txProposalsUpdated', function() { w.on('txProposalsUpdated', function() {
@ -572,8 +574,9 @@ Identity.prototype.createWallet = function(opts, cb) {
var w = new walletClass(opts); var w = new walletClass(opts);
self.bindWallet(w); self.wallets[w.getId()] = w;
self.updateFocusedTimestamp(w.getId()); self.updateFocusedTimestamp(w.getId());
self.bindWallet(w);
self.storeWallet(w, function(err) { self.storeWallet(w, function(err) {
if (err) return cb(err); if (err) return cb(err);
@ -664,15 +667,16 @@ Identity.prototype.decodeSecret = function(secret) {
* @return {string} walletId * @return {string} walletId
*/ */
Identity.prototype.getLastFocusedWalletId = function() { Identity.prototype.getLastFocusedWalletId = function() {
var max = _.max(this.focusedTimestamp); if (this.walletIds.length == 0) return undefined;
var aId = _.findKey(this.wallets) || this.walletIds[0];
var max = _.max(this.focusedTimestamps);
if (!max) if (!max)
return aId; return this.walletIds[0];
return _.findKey(this.focusedTimestamps, function(ts) { return _.findKey(this.focusedTimestamps, function(ts) {
return ts == max; return ts == max;
}) || aId; }) || this.walletIds[0];
}; };
Identity.prototype.updateFocusedTimestamp = function(wid) { 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="row hide-for-large-up">
<div class="medium-12 small-12 columns"> <div class="medium-12 small-12 columns">
<h1 translate>Home</h1> <h1 translate>Home</h1>