Fix disclaimer

This commit is contained in:
Gustavo Maximiliano Cortez 2015-12-05 20:50:31 -03:00
commit bdfa89115d
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
5 changed files with 60 additions and 50 deletions

View file

@ -4,16 +4,6 @@ angular.module('copayApp.controllers').controller('disclaimerController',
function($scope, $timeout, $log, profileService, isCordova, storageService, applicationService, gettextCatalog, uxLanguage, go) {
self = this;
$scope.goHome = function() {
$scope.error = "";
profileService.storeDisclaimer(function(err) {
if (err) {
$scope.error = err;
$scope.$apply();
} else go.walletHome();
});
};
var create = function() {
$scope.creatingProfile = true;
profileService.create({}, function(err) {

View file

@ -125,22 +125,19 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.initGlidera();
self.setCustomBWSFlag();
profileService.checkDisclaimer(function(v) {
if (v) self.disclaimerAccepted = true;
if (fc.isPrivKeyExternal()) {
self.needsBackup = false;
self.setCustomBWSFlag();
if (fc.isPrivKeyExternal()) {
self.needsBackup = false;
self.openWallet();
} else {
storageService.getBackupFlag(self.walletId, function(err, val) {
if (!fc.credentials.mnemonic)
self.needsBackup = false;
else
self.needsBackup = self.network == 'testnet' ? false : !val;
self.openWallet();
} else {
storageService.getBackupFlag(self.walletId, function(err, val) {
if (!fc.credentials.mnemonic)
self.needsBackup = false;
else
self.needsBackup = self.network == 'testnet' ? false : !val;
self.openWallet();
});
}
});
});
}
});
};
@ -151,6 +148,28 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.usingCustomBWS = config.bwsFor && config.bwsFor[self.walletId] && (config.bwsFor[self.walletId] != defaults.bws.url);
};
self.agreeDisclaimer = function() {
var profile = profileService.profile;
if (profile) profile.agreeDisclaimer = true;
self.disclaimerAccepted = true;
profileService.storeDisclaimer(function(err) {
if (err) $log.error(err);
go.walletHome();
});
};
self.checkDisclaimer = function() {
if (self.disclaimerAccepted == true) {
go.walletHome();
return;
}
profileService.checkDisclaimer(function(v) {
if (v) {
self.agreeDisclaimer();
} else go.path('disclaimer');
});
};
self.setTab = function(tab, reset, tries, switchState) {
tries = tries || 0;
@ -975,6 +994,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
};
self.openMenu = function() {
if (!self.disclaimerAccepted) return;
go.swipe(true);
};
@ -1220,7 +1240,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$rootScope.$on('Local/Resume', function(event) {
$log.debug('### Resume event');
if (!self.disclaimerAccepted) go.path('disclaimer');
self.checkDisclaimer();
self.debouncedUpdate();
});
@ -1343,17 +1363,16 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.setUxLanguage();
self.setFocusedWallet();
self.updateTxHistory();
if (self.disclaimerAccepted) go.walletHome();
storageService.getCleanAndScanAddresses(function(err, walletId) {
if (walletId && profileService.walletClients[walletId]) {
$log.debug('Clear last address cache and Scan ', walletId);
addressService.expireAddress(walletId, function(err) {
self.startScan(walletId);
});
storageService.removeCleanAndScanAddresses(function() {});
}
self.checkDisclaimer();
storageService.getCleanAndScanAddresses(function(err, walletId) {
if (walletId && profileService.walletClients[walletId]) {
$log.debug('Clear last address cache and Scan ', walletId);
addressService.expireAddress(walletId, function(err) {
self.startScan(walletId);
});
storageService.removeCleanAndScanAddresses(function() {});
}
});
});
$rootScope.$on('Local/SetTab', function(event, tab, reset) {