safer address cache

This commit is contained in:
Matias Alejo Garcia 2015-05-30 23:15:43 -03:00
parent 55585f0a94
commit ab44d80f3b
2 changed files with 13 additions and 12 deletions

View File

@ -222,8 +222,8 @@
</div>
<div class="text-center" ng-click="home.copyAddress(home.addr)">
<qrcode size="220" data="bitcoin:{{home.addr}}"></qrcode>
<div class="text-center" ng-click="home.copyAddress(home.addr[index.walletId])">
<qrcode size="220" data="bitcoin:{{home.addr[index.walletId]}}"></qrcode>
<div ng-show="home.generatingAddress" style="position:relative; top:-226px; height:0px">
<div style="height:220px; width:220px; margin:auto; background: url(img/qr.png) white">
<div class="spinner" style="margin-top:80px">
@ -237,7 +237,7 @@
</div>
<div class="m10t" >
<h4 ng-class="{'enable_text_select': !index.isCordova}" class="size-12">
{{home.generatingAddress ? '...' : home.addr}}
{{home.generatingAddress ? '...' : home.addr[index.walletId]}}
</h4>
</div>
@ -246,7 +246,7 @@
<div class="m10t text-center" ng-show="index.isCordova">
<span class="button outline dark-gray tiny round"
ng-click="home.shareAddress(home.addr)">
ng-click="home.shareAddress(home.addr[index.walletId])">
<i class="fi-share"></i>
<span translate>Share address</span>
</span>

View File

@ -23,7 +23,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
this.isRateAvailable = false;
this.showScanner = false;
this.isMobile = isMobile.any();
this.addr = null;
this.addr = {};
var disableScannerListener = $rootScope.$on('dataScanned', function(event, data) {
self.setForm(data);
@ -42,7 +42,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
});
var disableFocusListener = $rootScope.$on('Local/NewFocusedWallet', function() {
self.addr = null;
self.addr = {};
self.resetForm();
});
@ -360,7 +360,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
return;
}
self.addrError = null;
self.addr = addr.address;
self.addr[fc.credentials.walletId] = addr.address;
storageService.storeLastAddress(fc.credentials.walletId, addr.address, function() {
self.generatingAddress = false;
@ -371,18 +371,19 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
this.setAddress = function() {
self.addrError = null;
if (self.addr)
return;
var fc = profileService.focusedClient;
if (!fc)
return;
if (self.addr[fc.credentials.walletId]) {
return;
}
$timeout(function() {
storageService.getLastAddress(fc.credentials.walletId, function(err, addr) {
if (addr) {
self.addr = addr;
self.addr[fc.credentials.walletId] = addr;
$scope.$digest();
} else {
self.setNewAddress();