faster tab switching

This commit is contained in:
Matias Alejo Garcia 2015-04-28 16:58:40 -03:00
commit a56507fe87
4 changed files with 20 additions and 13 deletions

View file

@ -224,7 +224,7 @@
</div>
<div class="row m20t">
<div class="large-12 columns">
<button class="button black expand radius" ng-click="home.newAddress()"
<button class="button black expand radius" ng-click="home.setNewAddress()"
ng-style="{'background-color':index.backgroundColor}" ng-disabled="home.blockUx || index.isOffline ||home.generatingAddress" translate>
Generate new address
</button>

View file

@ -406,8 +406,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
});
if (used) {
$log.debug('Address ' + addr + ' was used. Cleaning Cache.')
$rootScope.$emit('Local/NeedNewAddress', err);
storageService.clearLastAddress(self.walletId, function(err) {
$rootScope.$emit('Local/NeedNewAddress', err);
if (cb) return cb();
});
};

View file

@ -37,21 +37,23 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
});
var disableAddrListener = $rootScope.$on('Local/NeedNewAddress', function() {
self.getAddress();
self.setNewAddress();
});
var disableFocusListener = $rootScope.$on('Local/NewFocusedWallet', function() {
self.addr = null;
self.resetForm();
});
var disableTabListener = $rootScope.$on('Local/TabChanged', function(e, tab) {
// This will slow down switch, do not add things here!
switch (tab) {
case 'receive':
// just to be sure we have an address
self.setAddress();
break;
case 'send':
self.resetError();
self.setInputs();
case 'receive':
self.getAddress();
break;
};
});
@ -277,8 +279,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
};
// Receive
this.newAddress = function() {
this.setNewAddress = function() {
var fc = profileService.focusedClient;
self.generatingAddress = true;
fc.createAddress(function(err, addr) {
@ -298,16 +299,19 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
});
};
this.getAddress = function() {
this.setAddress = function() {
if (self.addr)
return;
var fc = profileService.focusedClient;
$timeout(function() {
storageService.getLastAddress(fc.credentials.walletId, function(err, addr) {
if (addr) {
self.addr = addr;
$scope.$digest();
} else {
self.newAddress();
self.setNewAddress();
}
$scope.$digest();
});
});
};
@ -399,7 +403,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
}, 1);
};
this.setInputs = function() {
this.setSendFormInputs = function() {
var unitToSat = this.unitToSatoshi;
var satToUnit = 1 / unitToSat;
/**
@ -812,5 +816,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
// Startup events
this.bindTouchDown();
this.setAddress();
this.setSendFormInputs();
});

View file

@ -74,6 +74,7 @@ angular.module('copayApp.services')
}
});
console.log('[profileService.js.76] BIND'); //TODO
client.on('notification', function(n) {
$log.debug('BWC Notification:', n);
notificationService.newBWCNotification(n,