From 9d6962f5d00bcaa69d4f6f09d496c6b2c8a133d0 Mon Sep 17 00:00:00 2001 From: Benoit Lavenier <benoit.lavenier@e-is.pro> Date: Tue, 10 Mar 2020 17:29:23 +0100 Subject: [PATCH] [fix] Force loading message to be hide, when wallet has been loaded sucessfully, or when error has been catched --- platforms/android | 2 +- www/js/controllers/app-controllers.js | 4 ++-- www/js/controllers/wallet-controllers.js | 9 ++++++--- www/js/services/wallet-services.js | 10 ++++++++-- www/plugins/es/js/services/invitation-services.js | 12 ++++++++---- www/plugins/es/js/services/message-services.js | 8 ++++++-- www/plugins/es/js/services/notification-services.js | 13 ++++++++++--- 7 files changed, 41 insertions(+), 17 deletions(-) diff --git a/platforms/android b/platforms/android index 43173695f..a7164ac82 160000 --- a/platforms/android +++ b/platforms/android @@ -1 +1 @@ -Subproject commit 43173695faa4d60229b1a6bc6f1bc11d1c262627 +Subproject commit a7164ac8252a1be336019464edfe58ad353ed950 diff --git a/www/js/controllers/app-controllers.js b/www/js/controllers/app-controllers.js index c14eff369..61f936d50 100644 --- a/www/js/controllers/app-controllers.js +++ b/www/js/controllers/app-controllers.js @@ -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) { diff --git a/www/js/controllers/wallet-controllers.js b/www/js/controllers/wallet-controllers.js index e14831fa9..a5fdc777f 100644 --- a/www/js/controllers/wallet-controllers.js +++ b/www/js/controllers/wallet-controllers.js @@ -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, diff --git a/www/js/services/wallet-services.js b/www/js/services/wallet-services.js index 6bd6bf47e..2c65a9b2d 100644 --- a/www/js/services/wallet-services.js +++ b/www/js/services/wallet-services.js @@ -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) { diff --git a/www/plugins/es/js/services/invitation-services.js b/www/plugins/es/js/services/invitation-services.js index befb724ef..d6e1bc374 100644 --- a/www/plugins/es/js/services/invitation-services.js +++ b/www/plugins/es/js/services/invitation-services.js @@ -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; } diff --git a/www/plugins/es/js/services/message-services.js b/www/plugins/es/js/services/message-services.js index 2009ad161..cc54982a5 100644 --- a/www/plugins/es/js/services/message-services.js +++ b/www/plugins/es/js/services/message-services.js @@ -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; } diff --git a/www/plugins/es/js/services/notification-services.js b/www/plugins/es/js/services/notification-services.js index 3591a6fb6..1b2c7187f 100644 --- a/www/plugins/es/js/services/notification-services.js +++ b/www/plugins/es/js/services/notification-services.js @@ -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; } -- GitLab