Adds cache for preferences, walletDetails

This commit is contained in:
Gustavo Maximiliano Cortez 2016-09-22 11:55:23 -03:00
commit ca292813eb
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
44 changed files with 271 additions and 241 deletions

View file

@ -1,33 +1,11 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesController',
function($scope, $rootScope, $timeout, $log, $stateParams, $ionicHistory, $ionicNavBarDelegate, gettextCatalog, configService, profileService, fingerprintService, walletService) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Wallet Preferences'));
function($scope, $rootScope, $timeout, $log, $stateParams, $ionicHistory, gettextCatalog, configService, profileService, fingerprintService, walletService) {
var wallet = profileService.getWallet($stateParams.walletId);
var walletId = wallet.credentials.walletId;
$scope.wallet = wallet;
$scope.init = function() {
$scope.externalSource = null;
if (!wallet)
return $ionicHistory.goBack();
var config = configService.getSync();
$scope.encryptEnabled = walletService.isEncrypted(wallet);
if (wallet.isPrivKeyExternal)
$scope.externalSource = wallet.getPrivKeyExternalSourceName() == 'ledger' ? 'Ledger' : 'Trezor';
$scope.touchIdAvailable = fingerprintService.isAvailable();
$scope.touchIdEnabled = config.touchIdFor ? config.touchIdFor[walletId] : null;
$scope.deleted = false;
if (wallet.credentials && !wallet.credentials.mnemonicEncrypted && !wallet.credentials.mnemonic) {
$scope.deleted = true;
}
};
$scope.encryptChange = function() {
if (!wallet) return;
var val = $scope.encryptEnabled;
@ -77,4 +55,25 @@ angular.module('copayApp.controllers').controller('preferencesController',
$log.debug('Touch Id status changed: ' + newStatus);
});
};
$scope.$on("$ionicView.beforeEnter", function(event, data){
$scope.externalSource = null;
if (!wallet)
return $ionicHistory.goBack();
var config = configService.getSync();
$scope.encryptEnabled = walletService.isEncrypted(wallet);
if (wallet.isPrivKeyExternal)
$scope.externalSource = wallet.getPrivKeyExternalSourceName() == 'ledger' ? 'Ledger' : 'Trezor';
$scope.touchIdAvailable = fingerprintService.isAvailable();
$scope.touchIdEnabled = config.touchIdFor ? config.touchIdFor[walletId] : null;
$scope.deleted = false;
if (wallet.credentials && !wallet.credentials.mnemonicEncrypted && !wallet.credentials.mnemonic) {
$scope.deleted = true;
}
});
});