deleting agree disclaimer flag in storage and adding to the storage profile

This commit is contained in:
Gabriel Bazán 2015-11-30 12:58:52 -03:00
parent 42aaf515c7
commit 3f7485ca8d
7 changed files with 62 additions and 58 deletions

View File

@ -1,4 +1,5 @@
<div class="splash content text-center"
ng-init="init()"
ng-controller="disclaimerController">
<div>
<div class="row">
@ -30,7 +31,18 @@
<div class="text-center size-12 text-warning" ng-show="error">
{{(error)|translate}}. <span translate>Retrying...</span>
</div>
<div class="onGoingProcess" ng-show="creatingProfile">
<div class="onGoingProcess-content" ng-style="{'background-color':'#222'}">
<div class="spinner">
<div class="rect1"></div>
<div class="rect2"></div>
<div class="rect3"></div>
<div class="rect4"></div>
<div class="rect5"></div>
</div>
<span translate>Creating Profile...</span>
</div>
</div>
<div class="start-button columns">
<button ng-disabled="creatingProfile" ng-click="goHome()" class="button black expand round size-12 text-spacing" translate>
I AGREE. GET STARTED

View File

@ -4,10 +4,14 @@ 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() {
storageService.setCopayDisclaimerFlag(function(err) {
storageService.getProfile(function(err, profile) {
profile.agreeDisclaimer = true;
storageService.storeProfile(profile, function() {
go.walletHome();
});
});
};
var create = function() {
@ -17,10 +21,10 @@ angular.module('copayApp.controllers').controller('disclaimerController',
if (err) {
$log.warn(err);
if (err == 'EEXISTS') {
storageService.getCopayDisclaimerFlag(function(err, val) {
if (val) return go.walletHome();
if (profileService.profile.agreeDisclaimer) return go.walletHome();
$scope.creatingProfile = false;
});
} else {
$scope.error = err;
$scope.$apply();
@ -36,8 +40,10 @@ angular.module('copayApp.controllers').controller('disclaimerController',
});
};
if (!profileService.profile)
create();
else
applicationService.restart();
storageService.getProfile(function(err, profile) {
if (!profile) create();
else $scope.creatingProfile = false;
});
});

View File

@ -135,8 +135,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.openWallet();
});
}
storageService.getCopayDisclaimerFlag(function(err, val) {
self.agreeDisclaimer = val;
storageService.getProfile(function(err, profile) {
self.agreeDisclaimer = profile.agreeDisclaimer;
});
});
};
@ -1328,8 +1328,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$rootScope.$on('Local/NewFocusedWallet', function() {
self.setFocusedWallet();
self.updateTxHistory();
storageService.getCopayDisclaimerFlag(function(err, val) {
if (val) go.walletHome();
storageService.getProfile(function(err, val) {
if (val.agreeDisclaimer) go.walletHome();
storageService.getCleanAndScanAddresses(function(err, walletId) {
if (walletId && profileService.walletClients[walletId]) {
$log.debug('Clear last address cache and Scan ', walletId);

View File

@ -15,15 +15,16 @@ Profile.create = function(opts) {
var x = new Profile();
x.createdOn = Date.now();
x.credentials = opts.credentials || [];
x.agreeDisclaimer = false;
return x;
};
Profile.fromObj = function(obj) {
var x = new Profile();
x.createdOn = obj.createdOn;
x.credentials = obj.credentials;
x.agreeDisclaimer = obj.agreeDisclaimer;
if (x.credentials[0] && typeof x.credentials[0] != 'object')
throw ("credentials should be an object");
@ -31,7 +32,6 @@ Profile.fromObj = function(obj) {
return x;
};
Profile.fromString = function(str) {
return Profile.fromObj(JSON.parse(str));
};
@ -39,5 +39,3 @@ Profile.fromString = function(str) {
Profile.prototype.toObj = function() {
return JSON.stringify(this);
};

View File

@ -471,7 +471,7 @@ angular
if ($stateParams.status == "pause")
return;
storageService.getCopayDisclaimerFlag(function(err, val) {
storageService.getProfile(function(err, profile) {
$log.debug('### State: ', $stateParams.status);
switch ($stateParams.status) {
@ -479,7 +479,7 @@ angular
$rootScope.$emit('Local/Resume');
break;
case 'backbutton':
var shouldExit = $stateParams.isHome == 'true' || !val;
var shouldExit = $stateParams.isHome == 'true' || !profile.agreeDisclaimer;
if (isCordova && shouldExit && !$rootScope.modalOpened) {
return navigator.app.exitApp();
} else {
@ -488,7 +488,7 @@ angular
break;
};
if (val) {
if (profile.agreeDisclaimer) {
go.walletHome(true);
} else {
$state.transitionTo('disclaimer');

View File

@ -134,10 +134,7 @@ angular.module('copayApp.services')
};
root.loadAndBindProfile = function(cb) {
storageService.getCopayDisclaimerFlag(function(err, val) {
if (!val) {
return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
} else {
storageService.getProfile(function(err, profile) {
if (err) {
$rootScope.$emit('Local/DeviceError', err);
@ -154,12 +151,12 @@ angular.module('copayApp.services')
return root.bindProfile(profile, cb);
})
} else {
if (!profile.agreeDisclaimer)
return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
$log.debug('Profile read');
return root.bindProfile(profile, cb);
}
});
}
});
};
root._seedWallet = function(opts, cb) {

View File

@ -120,7 +120,6 @@ angular.module('copayApp.services')
root.getProfile = function(cb) {
storage.get('profile', function(err, str) {
if (err || !str)
return cb(err);
@ -199,14 +198,6 @@ angular.module('copayApp.services')
storage.remove('config', cb);
};
root.setCopayDisclaimerFlag = function(cb) {
storage.set('agreeDisclaimer', true, cb);
};
root.getCopayDisclaimerFlag = function(cb) {
storage.get('agreeDisclaimer', cb);
};
root.setRemotePrefsStoredFlag = function(cb) {
storage.set('remotePrefStored', true, cb);
};