Commit 9d6962f5 authored by Benoit Lavenier's avatar Benoit Lavenier

[fix] Force loading message to be hide, when wallet has been loaded...

[fix] Force loading message to be hide, when wallet has been loaded sucessfully, or when error has been catched
parent 79097c1c
Subproject commit 43173695faa4d60229b1a6bc6f1bc11d1c262627
Subproject commit a7164ac8252a1be336019464edfe58ad353ed950
......@@ -342,10 +342,10 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $
});
}
else {
UIUtils.loading.hide();
UIUtils.loading.hide(10);
}
})
.catch(UIUtils.onError());
.catch(UIUtils.onError('ERROR.LOGOUT'));
};
// Do authentification
$scope.doAuth = function(options) {
......
......@@ -91,7 +91,7 @@ function WalletController($scope, $rootScope, $q, $ionicPopup, $timeout, $state,
}
else {
// update view (to refresh avatar + plugin data, such as profile, subscriptions...)
UIUtils.loading.hide();
UIUtils.loading.hide(10);
$timeout($scope.updateView, 300);
}
};
......@@ -108,12 +108,14 @@ function WalletController($scope, $rootScope, $q, $ionicPopup, $timeout, $state,
$scope.showQRCode();
if (wallet.isDefault()) $scope.showHelpTip();
$scope.addListeners();
UIUtils.loading.hide(); // loading could have be open (e.g. new account)
UIUtils.loading.hide(10); // loading could have be open (e.g. new account)
})
.catch(function(err){
if (err === 'CANCELLED') {
$scope.showHome();
return $scope.showHome();
}
UIUtils.onError('ERROR.LOAD_WALLET_DATA_ERROR')(err);
});
};
......@@ -467,6 +469,7 @@ function WalletController($scope, $rootScope, $q, $ionicPopup, $timeout, $state,
};
$scope.showQRCode = function(timeout) {
if (!$scope.qrcodeId || !$scope.formData.pubkey) return; // Skip
if (!$scope.qrcode) {
$scope.qrcode = new QRCode(
$scope.qrcodeId,
......
......@@ -235,7 +235,10 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
})
.then(function() {
if (options && options.silent) {
UIUtils.loading.hide();
UIUtils.loading.hide(10);
}
else {
UIUtils.loading.hide(1000);
}
return keepAuth ? data : angular.merge({}, data, authData);
......@@ -942,7 +945,10 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
})
.then(function() {
data.loaded = true;
console.debug("[wallet] Loaded {{0}} full data in {1}s".format(data.pubkey.substr(0,8), Date.now() - now));
console.debug("[wallet] Loaded {{0}} full data in {1}ms".format(data.pubkey.substr(0,8), Date.now() - now));
// Make sure to hide loading, because sometimes it stay - should fix freeze screen
UIUtils.loading.hide(1000);
return data;
})
.catch(function(err) {
......
......@@ -12,7 +12,7 @@ angular.module('cesium.es.invitation.services', ['cesium.platform',
})
.factory('esInvitation', function($rootScope, $q, CryptoUtils, csPlatform, Api, esHttp, csWallet, esWallet, csWot, esNotification) {
.factory('esInvitation', function($rootScope, $q, $timeout, CryptoUtils, csPlatform, Api, esHttp, csWallet, esWallet, csWot, esNotification) {
'ngInject';
var
......@@ -51,7 +51,9 @@ angular.module('cesium.es.invitation.services', ['cesium.platform',
function onWalletLoad(data, deferred) {
deferred = deferred || $q.defer();
if (!data || !data.pubkey) {
deferred.resolve();
$timeout(function() {
deferred.resolve(data);
});
return deferred.promise;
}
......@@ -61,8 +63,10 @@ angular.module('cesium.es.invitation.services', ['cesium.platform',
// Skip if loaded less than 1 min ago
// (This is need to avoid reload on login AND load phases)
if (data.invitations && data.invitations.time && (time - data.invitations.time < 30 /*=30s*/)) {
console.debug('[ES] [invitation] Skipping load (loaded '+(time - data.invitations.time)+'s ago)');
deferred.resolve();
console.debug('[ES] [invitation] Skipping load (loaded {0}s ago)'.format(time - data.invitations.time));
$timeout(function() {
deferred.resolve(data);
});
return deferred.promise;
}
......
......@@ -48,7 +48,9 @@ angular.module('cesium.es.message.services', ['ngResource', 'cesium.platform',
deferred = deferred || $q.defer();
if (!data || !data.pubkey) {
deferred.resolve();
$timeout(function() {
deferred.resolve(data);
});
return deferred.promise;
}
......@@ -59,7 +61,9 @@ angular.module('cesium.es.message.services', ['ngResource', 'cesium.platform',
// (This is need to avoid reload on login AND load phases)
if (data.messages && data.messages.time && (time - data.messages.time < 30 /*=30s*/)) {
console.debug('[ES] [message] Skipping load (loaded '+(time - data.messages.time)+'s ago)');
deferred.resolve();
$timeout(function() {
deferred.resolve(data);
});
return deferred.promise;
}
......
......@@ -327,7 +327,9 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es
function onWalletLoad(data, deferred) {
deferred = deferred || $q.defer();
if (!data || !data.pubkey || !data.keypair) {
deferred.resolve();
$timeout(function() {
deferred.resolve(data);
});
return deferred.promise;
}
......@@ -341,7 +343,9 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es
data.notifications.warnCount = countWarnEvents(data);
console.debug('[ES] [notification] Skipping load (loaded '+(time - data.notifications.time)+'s ago)');
deferred.resolve();
$timeout(function() {
deferred.resolve(data);
});
return deferred.promise;
}
......@@ -373,7 +377,10 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es
console.debug('[ES] [notification] Loaded count (' + unreadCount + ') in '+(Date.now()-now)+'ms');
deferred.resolve(data);
})
.catch(deferred.reject);
.catch(function(err){
console.error('Error while counting notification: ' + (err.message ? err.message : err));
deferred.resolve(data);
});
return deferred.promise;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment