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

- Fix settings reloading

parent d706e489
No related branches found
No related tags found
No related merge requests found
{
"name": "cesium",
"version": "0.1.0",
"version": "0.1.1",
"description": "A webapp client for Duniter network",
"dependencies": {
"gulp": "^3.9.1",
......
......@@ -14,8 +14,8 @@ angular.module("cesium.config", [])
"TIMEOUT": 4000,
"DEBUG": false,
"NATIVE_TRANSITION": false,
"VERSION": "0.1.0",
"BUILD_DATE": "2016-05-26T20:53:57.821Z"
"VERSION": "0.1.1",
"BUILD_DATE": "2016-05-26T21:43:41.439Z"
})
;
\ No newline at end of file
......@@ -34,13 +34,16 @@ function SettingsController($scope, $state, UIUtils, Wallet, $translate, BMA, $q
$scope.loading = true;
$scope.$on('$ionicView.enter', function(e, $state) {
UIUtils.loading.show();
$scope.loading = true; // to avoid the call of Wallet.store()
$scope.loadWallet()
.then(function(walletData) {
$scope.formData.useRelative = walletData.settings.useRelative;
$scope.formData.node = walletData.settings.node;
$scope.formData.useLocalStorage = walletData.settings.useLocalStorage;
if (walletData.settings.locale && walletData.settings.locale.id) {
$scope.formData.locale = _.findWhere($scope.locales, {id: walletData.settings.locale.id});
}
UIUtils.loading.hide();
$scope.loading = false;
})
......
......@@ -31,10 +31,8 @@ function WalletController($scope, $state, $q, $ionicPopup, $ionicActionSheet, $t
$scope.loadWallet()
.then(function(wallet) {
$scope.updateWalletView(wallet);
$scope.showFab('fab-transfer');
UIUtils.loading.hide();
$timeout(function () {
document.getElementById('fab-transfer').classList.toggle('on', true);
}, 900);
});
});
......
......@@ -123,10 +123,8 @@ function WotIdentityViewController($scope, $state, BMA, Wallet, UIUtils, $q, $ti
});
$scope.loadIdentity = function(pub) {
//UIUtils.loading.show();
var onLoadFinish = function() {
$scope.loaded = true;
//UIUtils.loading.hide();
$timeout(function() {
UIUtils.motion.fadeSlideInRight({
......
......@@ -12,7 +12,8 @@ angular.module('cesium.wallet.services', ['ngResource', 'cesium.bma.services', '
useRelative: true,
timeWarningExpire: 129600 /*TODO: =1.5j est-ce suffisant ?*/,
useLocalStorage: false,
node: BMA.node.url
node: BMA.node.url,
locale: {id: $translate.use()}
},
data = {
......@@ -39,7 +40,7 @@ angular.module('cesium.wallet.services', ['ngResource', 'cesium.bma.services', '
settings: {
useRelative: defaultSettings.useRelative,
timeWarningExpire: defaultSettings.timeWarningExpire,
locale: {id: $translate.use()},
locale: defaultSettings.locale,
useLocalStorage: defaultSettings.useLocalStorage,
node: defaultSettings.node
}
......@@ -190,7 +191,7 @@ angular.module('cesium.wallet.services', ['ngResource', 'cesium.bma.services', '
}
},
restore = function() {
restore = function(enableLoadData) {
return $q(function(resolve, reject){
var settings = localStorage.getObject('CESIUM_SETTINGS');
var dataStr = localStorage.get('CESIUM_DATA');
......@@ -212,6 +213,16 @@ angular.module('cesium.wallet.services', ['ngResource', 'cesium.bma.services', '
if (storedData && storedData.keypair && storedData.pubkey) {
data.keypair = storedData.keypair;
data.pubkey = storedData.pubkey;
data.loaded = false;
if (enableLoadData) {
loadData()
.then(function() {
resolve();
})
.catch(function(err) {
reject(err);
});
}
}
resolve();
})
......@@ -365,6 +376,60 @@ angular.module('cesium.wallet.services', ['ngResource', 'cesium.bma.services', '
});
},
loadParameters = function() {
return $q(function(resolve, reject) {
BMA.currency.parameters()
.then(function(json){
data.currency = json.currency;
data.parameters = json;
resolve();
})
.catch(function(err) {
data.currency = null;
data.parameters = null;
reject(err);
});
});
},
loadUDs = function() {
return $q(function(resolve, reject) {
BMA.blockchain.stats.ud()
.then(function(res){
if (res.result.blocks.length) {
var lastBlockWithUD = res.result.blocks[res.result.blocks.length - 1];
return BMA.blockchain.block({ block: lastBlockWithUD })
.then(function(block){
data.currentUD = block.dividend;
resolve();
})
.catch(function(err) {
data.currentUD = null;
reject(err);
});
}
})
.catch(function(err) {
data.currentUD = null;
reject(err);
});
});
},
loadMembers = function() {
return $q(function(resolve, reject) {
BMA.wot.members()
.then(function(json){
data.members = json.results;
resolve();
})
.catch(function(err) {
data.members = [];
reject(err);
});
});
},
loadAvatar = function() {
return $q(function(resolve, reject) {
if (!Registry) {
......@@ -400,29 +465,13 @@ angular.module('cesium.wallet.services', ['ngResource', 'cesium.bma.services', '
$q.all([
// Get currency parameters
BMA.currency.parameters()
.then(function(json){
data.currency = json.currency;
data.parameters = json;
}),
loadParameters(),
// Get the UD informations
BMA.blockchain.stats.ud()
.then(function(res){
if (res.result.blocks.length) {
var lastBlockWithUD = res.result.blocks[res.result.blocks.length - 1];
return BMA.blockchain.block({ block: lastBlockWithUD })
.then(function(block){
data.currentUD = block.dividend;
});
}
}),
// Get UDs
loadUDs(),
// Get members
BMA.wot.members()
.then(function(json){
data.members = json.results;
}),
loadMembers(),
// Get sources
loadSources(false),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment