diff --git a/public/index.html b/public/index.html index 3e763dc79..56a114dec 100644 --- a/public/index.html +++ b/public/index.html @@ -18,7 +18,7 @@ ng-controller="indexController as index" ng-swipe-disable-mouse ng-swipe-left="index.closeMenu()" - ng-swipe-right="index.agreeDisclaimer() ? index.openMenu() : null"> + ng-swipe-right="index.openMenu()">
diff --git a/public/views/disclaimer.html b/public/views/disclaimer.html index b8bc3efb4..639b73ad8 100644 --- a/public/views/disclaimer.html +++ b/public/views/disclaimer.html @@ -1,56 +1,54 @@
-
-
-
- icon + ng-controller="disclaimerController as disclaimer" ng-init="disclaimer.init()"> +
+
+ icon +
+
+
+ WELCOME TO COPAY +

A multisignature bitcoin wallet

-
-
- WELCOME TO COPAY -

A multisignature bitcoin wallet

-
-
-
-
-

-

Terms of Use
-
-

-
-
-
- - +
+
+

+

Terms of Use
+

-
-

I affirm that I have read, understood, and agree with these terms.

-
-
+
+
-
- {{(error)|translate}}. Retrying... -
-
-
-
-
-
-
-
-
-
- Creating Profile... -
+ +
+

I affirm that I have read, understood, and agree with these terms.

+
+
+ +
+ {{(error)|translate}}. Retrying...
-
- +
+
+
+
+
+
+
+
+ Creating Profile... +
+
+
+
diff --git a/src/js/controllers/disclaimer.js b/src/js/controllers/disclaimer.js index c26ddcb30..853b496be 100644 --- a/src/js/controllers/disclaimer.js +++ b/src/js/controllers/disclaimer.js @@ -3,18 +3,6 @@ angular.module('copayApp.controllers').controller('disclaimerController', function($scope, $timeout, $log, profileService, isCordova, storageService, applicationService, gettextCatalog, uxLanguage, go) { self = this; - $scope.lang = uxLanguage.currentLanguage; - - $scope.goHome = function() { - $scope.error = ""; - profileService.storeDisclaimer(function(err) { - if (err) { - $scope.error = err; - $log.warn(err); - $scope.$apply(); - } else go.walletHome(); - }); - }; var create = function() { $scope.creatingProfile = true; @@ -35,13 +23,16 @@ angular.module('copayApp.controllers').controller('disclaimerController', }); }; - storageService.getProfile(function(err, profile) { - if (!profile) create(); - else $scope.creatingProfile = false; + this.init = function() { + self.lang = uxLanguage.currentLanguage; + storageService.getProfile(function(err, profile) { + if (!profile) create(); + else $scope.creatingProfile = false; - //compatible - storageService.getCopayDisclaimerFlag(function(err, val) { - if (val) go.walletHome(); + //compatible + profileService.isDisclaimerAccepted(function(val) { + if (val) go.walletHome(); + }); }); - }); + }; }); diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index f90539b99..d6d88c512 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -125,7 +125,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r self.initGlidera(); - self.setCustomBWSFlag(); + self.setCustomBWSFlag(); if (fc.isPrivKeyExternal()) { self.needsBackup = false; self.openWallet(); @@ -141,14 +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; - }); - }; - self.setCustomBWSFlag = function() { var defaults = configService.getDefaults(); var config = configService.getSync(); @@ -156,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.acceptDisclaimer = function() { + var profile = profileService.profile; + if (profile) profile.disclaimerAccepted = true; + self.disclaimerAccepted = true; + profileService.setDisclaimerAccepted(function(err) { + if (err) $log.error(err); + go.walletHome(); + }); + }; + + self.isDisclaimerAccepted = function() { + if (self.disclaimerAccepted == true) { + go.walletHome(); + return; + } + profileService.isDisclaimerAccepted(function(v) { + if (v) { + self.acceptDisclaimer(); + } else go.path('disclaimer'); + }); + }; + self.setTab = function(tab, reset, tries, switchState) { tries = tries || 0; @@ -980,6 +994,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r }; self.openMenu = function() { + if (!self.disclaimerAccepted) return; go.swipe(true); }; @@ -1168,10 +1183,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r }); }); - $rootScope.$on('Local/NewFocusedWallet', function() { - self.setUxLanguage(); - }); - $rootScope.$on('Local/LanguageSettingUpdated', function() { self.setUxLanguage(); self.updateRemotePreferences({ @@ -1229,6 +1240,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r $rootScope.$on('Local/Resume', function(event) { $log.debug('### Resume event'); + self.isDisclaimerAccepted(); self.debouncedUpdate(); }); @@ -1348,24 +1360,18 @@ angular.module('copayApp.controllers').controller('indexController', function($r }); $rootScope.$on('Local/NewFocusedWallet', function() { + self.setUxLanguage(); self.setFocusedWallet(); self.updateTxHistory(); - storageService.getProfile(function(err, profile) { - if (profile && profile.agreeDisclaimer) go.walletHome(); - - //compatible - storageService.getCopayDisclaimerFlag(function(err, val) { - if (val) 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.isDisclaimerAccepted(); + 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() {}); + } }); }); diff --git a/src/js/models/profile.js b/src/js/models/profile.js index 46d78bb3b..4b57a0f66 100644 --- a/src/js/models/profile.js +++ b/src/js/models/profile.js @@ -15,7 +15,7 @@ Profile.create = function(opts) { var x = new Profile(); x.createdOn = Date.now(); x.credentials = opts.credentials || []; - x.agreeDisclaimer = false; + x.disclaimerAccepted = false; return x; }; @@ -24,7 +24,7 @@ Profile.fromObj = function(obj) { x.createdOn = obj.createdOn; x.credentials = obj.credentials; - x.agreeDisclaimer = obj.agreeDisclaimer; + x.disclaimerAccepted = obj.disclaimerAccepted; if (x.credentials[0] && typeof x.credentials[0] != 'object') throw ("credentials should be an object"); diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index 317d48aa5..40bb3260f 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -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,13 +127,21 @@ angular.module('copayApp.services') if (err) return cb(err); root._setFocus(focusedWalletId, function() { $rootScope.$emit('Local/ProfileBound'); - return cb(); + root.isDisclaimerAccepted(function(val) { + if (!val) { + return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer')); + } + else { + return cb(); + } + }); }); }); }); + }; - root.loadAndBindProfile = function(cb) { + root.loadAndBindProfile = function(cb) { storageService.getProfile(function(err, profile) { if (err) { $rootScope.$emit('Local/DeviceError', err); @@ -150,13 +158,8 @@ angular.module('copayApp.services') return root.bindProfile(profile, cb); }) } else { - storageService.getCopayDisclaimerFlag(function(err, val) { - if (!profile.agreeDisclaimer) { - if (!val) return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer')); - } - $log.debug('Profile read'); - return root.bindProfile(profile, cb); - }); + $log.debug('Profile read'); + return root.bindProfile(profile, cb); } }); }; @@ -518,14 +521,38 @@ angular.module('copayApp.services') }); }; - root.storeDisclaimer = function(cb) { + root.setDisclaimerAccepted = function(cb) { storageService.getProfile(function(err, profile) { - profile.agreeDisclaimer = true; - storageService.storeProfile(profile, function() { + profile.disclaimerAccepted = true; + storageService.storeProfile(profile, function(err) { return cb(err); }); }); - } + }; + + root.isDisclaimerAccepted = function(cb) { + storageService.getProfile(function(err, profile) { + if (profile && profile.disclaimerAccepted) + return cb(true); + else if (profile && !profile.disclaimerAccepted) { + storageService.getCopayDisclaimerFlag(function(err, val) { + if (val) { + profile.disclaimerAccepted = true; + storageService.storeProfile(profile, function(err) { + if (err) $log.error(err); + return cb(true); + }); + } + else { + return cb(); + } + }); + } + else { + return cb(); + } + }); + }; root.importLegacyWallet = function(username, password, blob, cb) { var walletClient = bwcService.getClient();