Enable cache for nav tabs

This commit is contained in:
Gustavo Maximiliano Cortez 2016-09-21 17:12:25 -03:00
parent b86f2e240d
commit 889ebb8c6c
No known key found for this signature in database
GPG Key ID: 15EDAD8D9F2EB1AF
9 changed files with 44 additions and 37 deletions

View File

@ -3,7 +3,7 @@
<ion-nav-title>{{'Home' | translate}}</ion-nav-title> <ion-nav-title>{{'Home' | translate}}</ion-nav-title>
</ion-nav-bar> </ion-nav-bar>
<ion-content class="padding" ng-controller="tabHomeController" ng-init="updateAllWallets(); nextStep()"> <ion-content class="padding">
<div class="list card homeTip" ng-show="homeTip"> <div class="list card homeTip" ng-show="homeTip">
<div class="item item-icon-right item-heading"> <div class="item item-icon-right item-heading">
<a ng-click="hideHomeTip()"><i class="icon ion-ios-close-empty close-home-tip"></i></a> <a ng-click="hideHomeTip()"><i class="icon ion-ios-close-empty close-home-tip"></i></a>

View File

@ -1,4 +1,4 @@
<ion-view id="tab-receive" ng-controller="tabReceiveController" ng-init="init()"> <ion-view id="tab-receive">
<ion-nav-bar class="bar-royal"> <ion-nav-bar class="bar-royal">
<ion-nav-title>{{'Receive' | translate}}</ion-nav-title> <ion-nav-title>{{'Receive' | translate}}</ion-nav-title>
<ion-nav-buttons side="secondary"> <ion-nav-buttons side="secondary">
@ -10,8 +10,11 @@
<ion-content> <ion-content>
<article id="address"> <article id="address">
<div class="row"> <div class="row">
<div class="m15t text-center col col-60 center-block" copy-to-clipboard="addr"> <div class="m15t text-center col center-block" copy-to-clipboard="addr">
<qrcode size="220" data="bitcoin:{{addr}}"></qrcode> <qrcode ng-if="addr" size="220" data="bitcoin:{{addr}}"></qrcode>
<div ng-if="!addr" style="height:220px; width:220px; margin:auto; background: white; padding-top: 20%;">
...
</div>
<div ng-if="wallet.needsBackup" class="assertive m10t" translate> <div ng-if="wallet.needsBackup" class="assertive m10t" translate>
Before receiving funds, you must backup your wallet. If this device is lost, it is impossible to access your funds without a backup. Before receiving funds, you must backup your wallet. If this device is lost, it is impossible to access your funds without a backup.
</div> </div>
@ -25,7 +28,7 @@
</div> </div>
</div> </div>
<div class="col" ng-class="{'center-block col-50': !isCordova || !addr}"> <div class="col" ng-class="{'center-block col-50': !isCordova || !addr}">
<div class="item item-icon-left" ng-click="setAddress(null, true)"> <div class="item item-icon-left" ng-click="setAddress(true)">
<i class="icon ion-ios-loop"></i> <i class="icon ion-ios-loop"></i>
<span translate>Next Address</span> <span translate>Next Address</span>
</div> </div>
@ -46,11 +49,7 @@
<span translate>No Wallet</span> <span translate>No Wallet</span>
</div> </div>
<div class="list" ng-if="wallets[0]"> <div class="list" ng-if="wallets[0]">
<!-- <div class="item item-icon-left" ng-click="setAddress(null, true)"> <wallets wallets="wallets"></wallets>
<i class="icon ion-ios-loop"></i>
<span translate>Next Address</span>
</div> -->
<wallets ng-if="wallets[0]" wallets="wallets"></wallets>
</div> </div>
</article> </article>
</ion-content> </ion-content>

View File

@ -3,7 +3,7 @@
<ion-nav-title>{{'Send' | translate}}</ion-nav-title> <ion-nav-title>{{'Send' | translate}}</ion-nav-title>
</ion-nav-bar> </ion-nav-bar>
<ion-content ng-controller="tabSendController" ng-init="init()"> <ion-content>
<div> <div>
<div class="item item-heading" translate>Recipient</div> <div class="item item-heading" translate>Recipient</div>
<label class="item item-input bitcoin-address"> <label class="item item-input bitcoin-address">

View File

@ -3,7 +3,7 @@
<ion-nav-title>{{'Global Settings' | translate}}</ion-nav-title> <ion-nav-title>{{'Global Settings' | translate}}</ion-nav-title>
</ion-nav-bar> </ion-nav-bar>
<ion-content ng-controller="tabSettingsController" ng-init="init()"> <ion-content>
<div class="list"> <div class="list">
<div class="item item-divider"></div> <div class="item item-divider"></div>
<a class="item item-icon-left item-icon-right" ui-sref="tabs.addressbook"> <a class="item item-icon-left item-icon-right" ui-sref="tabs.addressbook">

View File

@ -172,7 +172,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
$scope.hideHomeTip = function() { $scope.hideHomeTip = function() {
$scope.homeTip = null; $scope.homeTip = null;
$state.transitionTo($state.current, null, { $state.transitionTo($state.current, null, {
reload: false, reload: true,
inherit: false, inherit: false,
notify: false notify: false
}); });
@ -204,4 +204,9 @@ angular.module('copayApp.controllers').controller('tabHomeController',
x(); x();
}); });
}); });
$scope.$on("$ionicView.enter", function(event, data){
$scope.nextStep();
$scope.updateAllWallets();
});
}); });

View File

@ -3,15 +3,11 @@
angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $timeout, $log, $ionicModal, storageService, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService) { angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $timeout, $log, $ionicModal, storageService, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService) {
$scope.isCordova = platformInfo.isCordova; $scope.isCordova = platformInfo.isCordova;
$scope.isNW = platformInfo.isNW;
$scope.init = function() { $scope.wallets = profileService.getWallets({
$scope.wallets = profileService.getWallets({ onlyComplete: true
onlyComplete: true });
});
$scope.isNW = platformInfo.isNW;
$scope.isCordova = platformInfo.isCordova;
if (!$scope.isCordova) $scope.checkTips();
}
$scope.checkTips = function(force) { $scope.checkTips = function(force) {
storageService.getReceiveTipsAccepted(function(err, accepted) { storageService.getReceiveTipsAccepted(function(err, accepted) {
@ -36,7 +32,7 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
} }
$scope.wallet = wallet; $scope.wallet = wallet;
$log.debug('Wallet changed: ' + wallet.name); $log.debug('Wallet changed: ' + wallet.name);
$scope.setAddress(wallet); $scope.setAddress();
}); });
$scope.shareAddress = function(addr) { $scope.shareAddress = function(addr) {
@ -46,25 +42,24 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
} }
}; };
$scope.setAddress = function(wallet, forceNew) { $scope.setAddress = function(forceNew) {
if ($scope.generatingAddress) return; if ($scope.generatingAddress) return;
var wallet = wallet || $scope.wallet;
$scope.addr = null; $scope.addr = null;
$scope.generatingAddress = true; $scope.generatingAddress = true;
$timeout(function() { $timeout(function() {
walletService.getAddress(wallet, forceNew, function(err, addr) { walletService.getAddress($scope.wallet, forceNew, function(err, addr) {
$scope.generatingAddress = false; $scope.generatingAddress = false;
if (err) { if (err || lodash.isEmpty(addr)) {
popupService.showAlert(gettextCatalog.getString('Error'), err); popupService.showAlert(gettextCatalog.getString('Error'), err || gettextCatalog.getString('Address is empty'));
} else { return;
if (addr)
$scope.addr = addr;
} }
$scope.addr = addr;
$scope.$apply(); $scope.$apply();
}); });
}, 1); }, 1);
}; };
if (!$scope.isCordova) $scope.checkTips();
}); });

View File

@ -4,7 +4,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
var originalList; var originalList;
$scope.init = function() { var updateList = function() {
originalList = []; originalList = [];
var wallets = profileService.getWallets({ var wallets = profileService.getWallets({
@ -83,8 +83,8 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
}); });
}; };
$scope.$on('modal.hidden', function() { $scope.$on("$ionicView.enter", function(event, data){
$scope.init(); updateList();
}); });
}); });

View File

@ -2,7 +2,7 @@
angular.module('copayApp.controllers').controller('tabSettingsController', function($scope, $rootScope, $log, $window, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) { angular.module('copayApp.controllers').controller('tabSettingsController', function($scope, $rootScope, $log, $window, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) {
$scope.init = function() { var updateConfig = function() {
var config = configService.getSync(); var config = configService.getSync();
var isCordova = platformInfo.isCordova; var isCordova = platformInfo.isCordova;
@ -44,7 +44,7 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
}, function(err) { }, function(err) {
$log.debug(err); $log.debug(err);
}); });
} };
$scope.spendUnconfirmedChange = function() { $scope.spendUnconfirmedChange = function() {
var opts = { var opts = {
@ -94,4 +94,8 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
}); });
}; };
$scope.$on("$ionicView.enter", function(event, data){
updateConfig();
});
}); });

View File

@ -17,7 +17,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
$urlRouterProvider.otherwise('/starting'); $urlRouterProvider.otherwise('/starting');
// NO CACHE // NO CACHE
$ionicConfigProvider.views.maxCache(0); //$ionicConfigProvider.views.maxCache(0);
// TABS BOTTOM // TABS BOTTOM
$ionicConfigProvider.tabs.position('bottom'); $ionicConfigProvider.tabs.position('bottom');
@ -193,6 +193,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
url: '/home/:fromOnboarding', url: '/home/:fromOnboarding',
views: { views: {
'tab-home': { 'tab-home': {
controller: 'tabHomeController',
templateUrl: 'views/tab-home.html', templateUrl: 'views/tab-home.html',
} }
} }
@ -201,6 +202,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
url: '/receive', url: '/receive',
views: { views: {
'tab-receive': { 'tab-receive': {
controller: 'tabReceiveController',
templateUrl: 'views/tab-receive.html', templateUrl: 'views/tab-receive.html',
} }
} }
@ -209,6 +211,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
url: '/send', url: '/send',
views: { views: {
'tab-send': { 'tab-send': {
controller: 'tabSendController',
templateUrl: 'views/tab-send.html', templateUrl: 'views/tab-send.html',
} }
} }
@ -217,6 +220,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
url: '/settings', url: '/settings',
views: { views: {
'tab-settings': { 'tab-settings': {
controller: 'tabSettingsController',
templateUrl: 'views/tab-settings.html', templateUrl: 'views/tab-settings.html',
} }
} }