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

@ -18,7 +18,7 @@
ng-controller="indexController as index" ng-controller="indexController as index"
ng-swipe-disable-mouse ng-swipe-disable-mouse
ng-swipe-left="index.closeMenu()" ng-swipe-left="index.closeMenu()"
ng-swipe-right="index.disclaimerAccepted ? index.openMenu() : null"> ng-swipe-right="index.openMenu()">
<div class="off-canvas-wrap" id="off-canvas-wrap"> <div class="off-canvas-wrap" id="off-canvas-wrap">
<div class="inner-wrap"> <div class="inner-wrap">

View file

@ -46,7 +46,7 @@
</div> </div>
</div> </div>
<div class="start-button columns"> <div class="start-button columns">
<button ng-disabled="creatingProfile" ng-click="goHome()" class="button black expand round size-12 text-spacing" translate> <button ng-disabled="creatingProfile" ng-click="index.agreeDisclaimer()" class="button black expand round size-12 text-spacing" translate>
I AGREE. GET STARTED I AGREE. GET STARTED
</button> </button>
</div> </div>

View file

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

View file

@ -126,21 +126,18 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.initGlidera(); self.initGlidera();
self.setCustomBWSFlag(); self.setCustomBWSFlag();
profileService.checkDisclaimer(function(v) { if (fc.isPrivKeyExternal()) {
if (v) self.disclaimerAccepted = true; self.needsBackup = false;
if (fc.isPrivKeyExternal()) { self.openWallet();
self.needsBackup = false; } 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(); 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.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) { self.setTab = function(tab, reset, tries, switchState) {
tries = tries || 0; tries = tries || 0;
@ -975,6 +994,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}; };
self.openMenu = function() { self.openMenu = function() {
if (!self.disclaimerAccepted) return;
go.swipe(true); go.swipe(true);
}; };
@ -1220,7 +1240,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$rootScope.$on('Local/Resume', function(event) { $rootScope.$on('Local/Resume', function(event) {
$log.debug('### Resume event'); $log.debug('### Resume event');
if (!self.disclaimerAccepted) go.path('disclaimer'); self.checkDisclaimer();
self.debouncedUpdate(); self.debouncedUpdate();
}); });
@ -1343,17 +1363,16 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.setUxLanguage(); self.setUxLanguage();
self.setFocusedWallet(); self.setFocusedWallet();
self.updateTxHistory(); self.updateTxHistory();
if (self.disclaimerAccepted) go.walletHome(); self.checkDisclaimer();
storageService.getCleanAndScanAddresses(function(err, walletId) {
storageService.getCleanAndScanAddresses(function(err, walletId) { if (walletId && profileService.walletClients[walletId]) {
if (walletId && profileService.walletClients[walletId]) { $log.debug('Clear last address cache and Scan ', walletId);
$log.debug('Clear last address cache and Scan ', walletId); addressService.expireAddress(walletId, function(err) {
addressService.expireAddress(walletId, function(err) { self.startScan(walletId);
self.startScan(walletId);
});
storageService.removeCleanAndScanAddresses(function() {});
}
}); });
storageService.removeCleanAndScanAddresses(function() {});
}
});
}); });
$rootScope.$on('Local/SetTab', function(event, tab, reset) { $rootScope.$on('Local/SetTab', function(event, tab, reset) {

View file

@ -127,18 +127,21 @@ angular.module('copayApp.services')
if (err) return cb(err); if (err) return cb(err);
root._setFocus(focusedWalletId, function() { root._setFocus(focusedWalletId, function() {
$rootScope.$emit('Local/ProfileBound'); $rootScope.$emit('Local/ProfileBound');
return cb(); root.checkDisclaimer(function(val) {
if (!val) {
return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
}
else {
return cb();
}
});
}); });
}); });
}); });
}; };
root.loadAndBindProfile = function(cb) { root.loadAndBindProfile = function(cb) {
root.checkDisclaimer(function(val) {
if (!val) {
return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
}
else {
storageService.getProfile(function(err, profile) { storageService.getProfile(function(err, profile) {
if (err) { if (err) {
$rootScope.$emit('Local/DeviceError', err); $rootScope.$emit('Local/DeviceError', err);
@ -159,8 +162,6 @@ angular.module('copayApp.services')
return root.bindProfile(profile, cb); return root.bindProfile(profile, cb);
} }
}); });
}
});
}; };
root._seedWallet = function(opts, cb) { root._seedWallet = function(opts, cb) {
@ -530,14 +531,14 @@ angular.module('copayApp.services')
}; };
root.checkDisclaimer = function(cb) { root.checkDisclaimer = function(cb) {
if (root.profile && root.profile.agreeDisclaimer) return cb(true);
storageService.getProfile(function(err, profile) { storageService.getProfile(function(err, profile) {
if (profile && profile.agreeDisclaimer) if (profile && profile.agreeDisclaimer)
return cb(true); return cb(true);
else if (profile && !profile.agreeDisclaimer) { else if (profile && !profile.agreeDisclaimer) {
storageService.getCopayDisclaimerFlag(function(err, val) { storageService.getCopayDisclaimerFlag(function(err, val) {
if (val) { if (val) {
root.storeDisclaimer(function(err) { profile.agreeDisclaimer = true;
storageService.storeProfile(profile, function(err) {
if (err) $log.error(err); if (err) $log.error(err);
return cb(true); return cb(true);
}); });