Skip to content
Snippets Groups Projects
Commit fe88da95 authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[fix] Make sure to save settings locally, event if Duniter node is down - fix #788

parent a4c3ff24
No related branches found
No related tags found
No related merge requests found
...@@ -84,10 +84,18 @@ function SettingsController($scope, $q, $ionicHistory, $ionicPopup, $timeout, $t ...@@ -84,10 +84,18 @@ function SettingsController($scope, $q, $ionicHistory, $ionicPopup, $timeout, $t
$q.all([ $q.all([
csSettings.ready(), csSettings.ready(),
csCurrency.parameters() csCurrency.parameters()
.then(function(parameters) {
return parameters && parameters.avgGenTime;
})
// Make sure to continue even if node is down - Fix #788
.catch(function(err) {
console.error("[settings] Could not not currency parameters. Using default 'avgGenTime' (300)", err);
return {avgGenTime: 300};
})
.then(function(parameters) { .then(function(parameters) {
_.each($scope.blockValidityWindows, function(blockCount) { _.each($scope.blockValidityWindows, function(blockCount) {
if (blockCount > 0) { if (blockCount > 0) {
$scope.blockValidityWindowLabels[blockCount].labelParams.time=parameters.avgGenTime * blockCount; $scope.blockValidityWindowLabels[blockCount].labelParams.time= parameters.avgGenTime * blockCount;
} }
}); });
}) })
...@@ -153,7 +161,7 @@ function SettingsController($scope, $q, $ionicHistory, $ionicPopup, $timeout, $t ...@@ -153,7 +161,7 @@ function SettingsController($scope, $q, $ionicHistory, $ionicPopup, $timeout, $t
.then(function(newNode) { .then(function(newNode) {
if (newNode.host === $scope.formData.node.host && if (newNode.host === $scope.formData.node.host &&
newNode.port === $scope.formData.node.port && newNode.port === $scope.formData.node.port &&
newNode.useSsl === $scope.formData.node.useSsl) { newNode.useSsl === $scope.formData.node.useSsl && !$scope.formData.node.temporary) {
return; // same node = nothing to do return; // same node = nothing to do
} }
UIUtils.loading.show(); UIUtils.loading.show();
...@@ -169,8 +177,8 @@ function SettingsController($scope, $q, $ionicHistory, $ionicPopup, $timeout, $t ...@@ -169,8 +177,8 @@ function SettingsController($scope, $q, $ionicHistory, $ionicPopup, $timeout, $t
}); });
} }
UIUtils.loading.hide(); UIUtils.loading.hide();
$scope.formData.node = newNode; angular.merge($scope.formData.node, newNode);
delete $scope.formData.temporary; delete $scope.formData.node.temporary;
BMA.copy(nodeBMA); BMA.copy(nodeBMA);
$scope.bma = BMA; $scope.bma = BMA;
......
...@@ -199,7 +199,7 @@ angular.module('cesium.settings.services', ['ngApi', 'cesium.config']) ...@@ -199,7 +199,7 @@ angular.module('cesium.settings.services', ['ngApi', 'cesium.config'])
angular.merge(data, newData); angular.merge(data, newData);
// Delete temporary properties, if false // Delete temporary properties, if false
if (!data.node.temporary) delete data.node.temporary; if (!newData.node.temporary || !data.node.temporary) delete data.node.temporary;
// Always force the usage of default settings // Always force the usage of default settings
// This is a workaround for DEV (TODO: implement edition in settings ?) // This is a workaround for DEV (TODO: implement edition in settings ?)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment