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

[fix] Notifications: do not mark as read if not auth

parent 426693a6
Branches
Tags
No related merge requests found
......@@ -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);
});
},
......
......@@ -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,
......
......@@ -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);
}
......
......@@ -175,14 +175,22 @@ 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)
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);
});
});
}
function onWalletReset(data) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment