Ref bootstrapping (disclaimer)
This commit is contained in:
parent
11462ce414
commit
a28f9c0e7f
5 changed files with 108 additions and 96 deletions
|
|
@ -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.agreeDisclaimer() ? index.openMenu() : null">
|
ng-swipe-right="index.disclaimerAccepted ? index.openMenu() : null">
|
||||||
|
|
||||||
<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">
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
<div class="splash content text-center"
|
<div class="splash content text-center"
|
||||||
ng-controller="disclaimerController">
|
ng-controller="disclaimerController as disclaimer" ng-init="disclaimer.init()">
|
||||||
<div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="container-image large-2 medium-2 small-2 medium-centered small-centered large-centered columns">
|
<div class="container-image large-2 medium-2 small-2 medium-centered small-centered large-centered columns">
|
||||||
<img src="img/icon-splash.png" alt="icon" width="100%">
|
<img src="img/icon-splash.png" alt="icon" width="100%">
|
||||||
|
|
@ -22,7 +21,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<p ng-show="lang != 'en'">
|
<p ng-show="disclaimer.lang != 'en'">
|
||||||
<a class="center" ng-click="$root.openExternalLink('https://copay.io/disclaimer')" translate>Official English Disclaimer</a>
|
<a class="center" ng-click="$root.openExternalLink('https://copay.io/disclaimer')" translate>Official English Disclaimer</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -53,4 +52,3 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,12 @@
|
||||||
angular.module('copayApp.controllers').controller('disclaimerController',
|
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.lang = uxLanguage.currentLanguage;
|
|
||||||
|
|
||||||
$scope.goHome = function() {
|
$scope.goHome = function() {
|
||||||
$scope.error = "";
|
$scope.error = "";
|
||||||
profileService.storeDisclaimer(function(err) {
|
profileService.storeDisclaimer(function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
$scope.error = err;
|
$scope.error = err;
|
||||||
$log.warn(err);
|
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
} else go.walletHome();
|
} else go.walletHome();
|
||||||
});
|
});
|
||||||
|
|
@ -35,13 +33,16 @@ angular.module('copayApp.controllers').controller('disclaimerController',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.init = function() {
|
||||||
|
self.lang = uxLanguage.currentLanguage;
|
||||||
storageService.getProfile(function(err, profile) {
|
storageService.getProfile(function(err, profile) {
|
||||||
if (!profile) create();
|
if (!profile) create();
|
||||||
else $scope.creatingProfile = false;
|
else $scope.creatingProfile = false;
|
||||||
|
|
||||||
//compatible
|
//compatible
|
||||||
storageService.getCopayDisclaimerFlag(function(err, val) {
|
profileService.checkDisclaimer(function(val) {
|
||||||
if (val) go.walletHome();
|
if (val) go.walletHome();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
self.initGlidera();
|
self.initGlidera();
|
||||||
|
|
||||||
self.setCustomBWSFlag();
|
self.setCustomBWSFlag();
|
||||||
|
profileService.checkDisclaimer(function(v) {
|
||||||
|
if (v) self.disclaimerAccepted = true;
|
||||||
if (fc.isPrivKeyExternal()) {
|
if (fc.isPrivKeyExternal()) {
|
||||||
self.needsBackup = false;
|
self.needsBackup = false;
|
||||||
self.openWallet();
|
self.openWallet();
|
||||||
|
|
@ -139,13 +141,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
self.agreeDisclaimer = function() {
|
|
||||||
storageService.getProfile(function(err, profile) {
|
|
||||||
if (profile && profile.agreeDisclaimer)
|
|
||||||
return profile.agreeDisclaimer;
|
|
||||||
return null;
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1168,10 +1163,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.$on('Local/NewFocusedWallet', function() {
|
|
||||||
self.setUxLanguage();
|
|
||||||
});
|
|
||||||
|
|
||||||
$rootScope.$on('Local/LanguageSettingUpdated', function() {
|
$rootScope.$on('Local/LanguageSettingUpdated', function() {
|
||||||
self.setUxLanguage();
|
self.setUxLanguage();
|
||||||
self.updateRemotePreferences({
|
self.updateRemotePreferences({
|
||||||
|
|
@ -1229,6 +1220,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.debouncedUpdate();
|
self.debouncedUpdate();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1348,14 +1340,11 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.$on('Local/NewFocusedWallet', function() {
|
$rootScope.$on('Local/NewFocusedWallet', function() {
|
||||||
|
self.setUxLanguage();
|
||||||
self.setFocusedWallet();
|
self.setFocusedWallet();
|
||||||
self.updateTxHistory();
|
self.updateTxHistory();
|
||||||
storageService.getProfile(function(err, profile) {
|
if (self.disclaimerAccepted) go.walletHome();
|
||||||
if (profile && profile.agreeDisclaimer) go.walletHome();
|
|
||||||
|
|
||||||
//compatible
|
|
||||||
storageService.getCopayDisclaimerFlag(function(err, val) {
|
|
||||||
if (val) go.walletHome();
|
|
||||||
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);
|
||||||
|
|
@ -1366,8 +1355,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$rootScope.$on('Local/SetTab', function(event, tab, reset) {
|
$rootScope.$on('Local/SetTab', function(event, tab, reset) {
|
||||||
self.setTab(tab, reset);
|
self.setTab(tab, reset);
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,11 @@ angular.module('copayApp.services')
|
||||||
};
|
};
|
||||||
|
|
||||||
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);
|
||||||
|
|
@ -150,12 +155,9 @@ angular.module('copayApp.services')
|
||||||
return root.bindProfile(profile, cb);
|
return root.bindProfile(profile, cb);
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
storageService.getCopayDisclaimerFlag(function(err, val) {
|
|
||||||
if (!profile.agreeDisclaimer) {
|
|
||||||
if (!val) return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
|
|
||||||
}
|
|
||||||
$log.debug('Profile read');
|
$log.debug('Profile read');
|
||||||
return root.bindProfile(profile, cb);
|
return root.bindProfile(profile, cb);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -521,11 +523,35 @@ angular.module('copayApp.services')
|
||||||
root.storeDisclaimer = function(cb) {
|
root.storeDisclaimer = function(cb) {
|
||||||
storageService.getProfile(function(err, profile) {
|
storageService.getProfile(function(err, profile) {
|
||||||
profile.agreeDisclaimer = true;
|
profile.agreeDisclaimer = true;
|
||||||
storageService.storeProfile(profile, function() {
|
storageService.storeProfile(profile, function(err) {
|
||||||
return cb(err);
|
return cb(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
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) {
|
||||||
|
if (err) $log.error(err);
|
||||||
|
return cb(true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return cb();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return cb();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
root.importLegacyWallet = function(username, password, blob, cb) {
|
root.importLegacyWallet = function(username, password, blob, cb) {
|
||||||
var walletClient = bwcService.getClient();
|
var walletClient = bwcService.getClient();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue