Fix disclaimer
This commit is contained in:
parent
a28f9c0e7f
commit
bdfa89115d
5 changed files with 60 additions and 50 deletions
|
|
@ -18,7 +18,7 @@
|
|||
ng-controller="indexController as index"
|
||||
ng-swipe-disable-mouse
|
||||
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="inner-wrap">
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<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
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ angular.module('copayApp.services')
|
|||
|
||||
root.bindProfile = function(profile, cb) {
|
||||
root.profile = profile;
|
||||
|
||||
|
||||
configService.get(function(err) {
|
||||
$log.debug('Preferences read');
|
||||
if (err) return cb(err);
|
||||
|
|
@ -127,18 +127,21 @@ angular.module('copayApp.services')
|
|||
if (err) return cb(err);
|
||||
root._setFocus(focusedWalletId, function() {
|
||||
$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.checkDisclaimer(function(val) {
|
||||
if (!val) {
|
||||
return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
|
||||
}
|
||||
else {
|
||||
root.loadAndBindProfile = function(cb) {
|
||||
storageService.getProfile(function(err, profile) {
|
||||
if (err) {
|
||||
$rootScope.$emit('Local/DeviceError', err);
|
||||
|
|
@ -159,8 +162,6 @@ angular.module('copayApp.services')
|
|||
return root.bindProfile(profile, cb);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
root._seedWallet = function(opts, cb) {
|
||||
|
|
@ -530,14 +531,14 @@ angular.module('copayApp.services')
|
|||
};
|
||||
|
||||
root.checkDisclaimer = function(cb) {
|
||||
if (root.profile && root.profile.agreeDisclaimer) return cb(true);
|
||||
storageService.getProfile(function(err, profile) {
|
||||
if (profile && profile.agreeDisclaimer)
|
||||
return cb(true);
|
||||
else if (profile && !profile.agreeDisclaimer) {
|
||||
storageService.getCopayDisclaimerFlag(function(err, val) {
|
||||
if (val) {
|
||||
root.storeDisclaimer(function(err) {
|
||||
profile.agreeDisclaimer = true;
|
||||
storageService.storeProfile(profile, function(err) {
|
||||
if (err) $log.error(err);
|
||||
return cb(true);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue