diff --git a/www/js/services/wallet-services.js b/www/js/services/wallet-services.js index ff0c1234d6d295830a4c70eabcf1eaa944c0f94e..99e2f4fc3a6296b8a7d6fa8742cca654ac727830 100644 --- a/www/js/services/wallet-services.js +++ b/www/js/services/wallet-services.js @@ -157,6 +157,9 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se return loadData(loadOptions); } }).then(function() { + if (options && options.silent) { + UIUtils.loading.hide(); + } return keepAuth ? data : angular.merge({}, data, authData); }); }, diff --git a/www/plugins/es/js/controllers/app-controllers.js b/www/plugins/es/js/controllers/app-controllers.js index 4d51aeb388532de59b6efcb2e7a7546247da0521..2a42c35f9457d89bf82df6d1400a6066a35adfb5 100644 --- a/www/plugins/es/js/controllers/app-controllers.js +++ b/www/plugins/es/js/controllers/app-controllers.js @@ -89,6 +89,14 @@ function ESMenuExtendController($scope, $state, PluginService, esSettings, UIUti }; $scope.showMessagesPopover = function(event) { + // Make sure tobe auth before opening this popover + if (!csWallet.isAuth()) { + return csWallet.auth().then(function(){ + UIUtils.loading.hide(); + return $scope.showMessagesPopover(event); // loop + }); + } + return UIUtils.popover.show(event, { templateUrl :'plugins/es/templates/message/popover_message.html', scope: $scope, diff --git a/www/plugins/es/js/controllers/notification-controllers.js b/www/plugins/es/js/controllers/notification-controllers.js index 88f7f39f856325e6f8f6acc896bd73c7f0b686ff..d84635dab96e45bd1fda71b04f2b7a448bd9746f 100644 --- a/www/plugins/es/js/controllers/notification-controllers.js +++ b/www/plugins/es/js/controllers/notification-controllers.js @@ -16,7 +16,7 @@ angular.module('cesium.es.notification.controllers', ['cesium.es.services']) } }, data: { - auth: true + login: true } }) ; @@ -95,6 +95,14 @@ function NotificationsController($scope, $rootScope, $ionicPopover, $state, $tim }; $scope.markAllAsRead = function() { + // Make sure to be auth before doing this + if (!csWallet.isAuth()) { + return csWallet.auth().then(function(){ + UIUtils.loading.hide(); + return $scope.markAllAsRead(); // loop + }); + } + $scope.hideActionsPopover(); if (!$scope.search.results.length) return; @@ -125,7 +133,10 @@ function NotificationsController($scope, $rootScope, $ionicPopover, $state, $tim }; $scope.select = function(item) { - if (item.markAsRead && typeof item.markAsRead == 'function') item.markAsRead(); + + if (item.markAsRead && typeof item.markAsRead == 'function') { + $timeout(item.markAsRead); + } if (item.state) { $state.go(item.state, item.stateParams); } diff --git a/www/plugins/es/js/services/notification-services.js b/www/plugins/es/js/services/notification-services.js index f84b539b6cafa4d03f0d6b3bbde339aaee3413bb..ff68c0423dd71e7af398c9f459dbbc114337977b 100644 --- a/www/plugins/es/js/services/notification-services.js +++ b/www/plugins/es/js/services/notification-services.js @@ -175,13 +175,21 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es console.error('[ES] [notification] Could not mark as read: no \'id\' found!', notification); return; } + + // user not auth: could not mark as read + if (!csWallet.isAuth()) return; + notification.read = true; - CryptoUtils.sign(notification.hash, csWallet.data.keypair) - .then(function(signature){ - return that.raw.postReadById(signature, {id:notification.id}); - }) - .catch(function(err) { - console.error('[ES] [notification] Error while trying to mark event as read.', err); + return csWallet.getKeypair() + .then(function(keypair) { + return CryptoUtils.sign(notification.hash, keypair) + .then(function(signature){ + return that.raw.postReadById(signature, {id:notification.id}); + }) + .catch(function(err) { + console.error('[ES] [notification] Error while trying to mark event as read.', err); + }); + }); }