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>
<div class="row m20t"> <div class="row m20t">
<div class="large-12 columns"> <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> ng-style="{'background-color':index.backgroundColor}" ng-disabled="home.blockUx || index.isOffline ||home.generatingAddress" translate>
Generate new address Generate new address
</button> </button>

View file

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

View file

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