save remote for new clients

This commit is contained in:
Matias Alejo Garcia 2015-06-29 22:40:39 -03:00
commit 7f65822790
4 changed files with 28 additions and 14 deletions

View file

@ -172,6 +172,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r
var prefs = opts.preferences || {};
var fc = profileService.focusedClient;
// Update this JIC.
var config = configService.getSync().wallet.settings;
self.unitName = config.unitName;
//prefs.email (may come from arguments)
prefs.language = self.defaultLanguageIsoCode;
prefs.unit = self.unitName;
@ -188,6 +192,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.handleError(err);
return cb(err);
}
if (!fc) return cb();
fc.getPreferences(function(err, preferences) {
if (err) {
@ -651,6 +656,17 @@ angular.module('copayApp.controllers').controller('indexController', function($r
});
});
$rootScope.$on('Local/ProfileBound', function() {
storageService.getRemotePrefsStoredFlag(function(err, val) {
if (err || val) return;
self.updateRemotePreferences({
saveAll: true
}, function() {
$log.debug('Remote preferences saved')
storageService.setRemotePrefsStoredFlag(function() {});
});
});
});
$rootScope.$on('Local/NewFocusedWallet', function() {
self.setUxLanguage();
@ -666,11 +682,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
});
$rootScope.$on('Local/UnitSettingUpdated', function(event) {
// This need to be done first, to update unitName
// updateAll do it, but async, later.
var config = configService.getSync().wallet.settings;
self.unitName = config.unitName;
self.updateAll();
self.updateTxHistory();
self.updateRemotePreferences({

View file

@ -74,7 +74,7 @@ angular
'main': {
templateUrl: 'views/splash.html',
controller: function($scope, $timeout, $log, profileService, storageService, go) {
storageService.getCopayDisclaimer(function(err, val) {
storageService.getCopayDisclaimerFlag(function(err, val) {
if (!val) go.path('disclaimer');
if (profileService.profile) {
@ -109,7 +109,7 @@ angular
'main': {
templateUrl: 'views/disclaimer.html',
controller: function($scope, $timeout, storageService, applicationService, go) {
storageService.getCopayDisclaimer(function(err, val) {
storageService.getCopayDisclaimerFlag(function(err, val) {
$scope.agreed = val;
$timeout(function(){
$scope.$digest();
@ -117,7 +117,7 @@ angular
});
$scope.agree = function() {
storageService.setCopayDisclaimer(function(err) {
storageService.setCopayDisclaimerFlag(function(err) {
$timeout(function(){
applicationService.restart();
}, 1000);

View file

@ -128,13 +128,16 @@ angular.module('copayApp.services')
root.setWalletClients();
storageService.getFocusedWalletId(function(err, focusedWalletId) {
if (err) return cb(err);
root._setFocus(focusedWalletId, cb);
root._setFocus(focusedWalletId, function() {
$rootScope.$emit('Local/ProfileBound');
return cb();
});
});
});
};
root.loadAndBindProfile = function(cb) {
storageService.getCopayDisclaimer(function(err, val) {
storageService.getCopayDisclaimerFlag(function(err, val) {
if (!val) {
return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
} else {

View file

@ -176,19 +176,19 @@ angular.module('copayApp.services')
storage.remove('config', cb);
};
root.setCopayDisclaimer = function(cb) {
root.setCopayDisclaimerFlag = function(cb) {
storage.set('agreeDisclaimer', true, cb);
};
root.getCopayDisclaimer = function(cb) {
root.getCopayDisclaimerFlag = function(cb) {
storage.get('agreeDisclaimer', cb);
};
root.setRemotePreferencesStored = function(cb) {
root.setRemotePrefsStoredFlag = function(cb) {
storage.set('remotePrefStored', true, cb);
};
root.getRemovePreferencesStored = function(cb) {
root.getRemotePrefsStoredFlag = function(cb) {
storage.get('remotePrefStored', cb);
};