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

[fix] Notifications: new notification (received by WebScoket) are not added to...

[fix] Notifications: new notification (received by WebScoket) are not added to popover ("duplicated id" error, from the ng-repeater)
parent 5a596193
No related branches found
No related tags found
No related merge requests found
...@@ -11,14 +11,15 @@ function EsNotification(json, markAsReadCallback) { ...@@ -11,14 +11,15 @@ function EsNotification(json, markAsReadCallback) {
// Avoid undefined errors // Avoid undefined errors
json = json || {}; json = json || {};
that.id = json.id || ('' + Date.now()); // Keep id if exists, otherwise create it from timestamp
that.type = json.type && json.type.toLowerCase(); that.type = json.type && json.type.toLowerCase();
that.time = json.time; that.time = json.time;
that.hash = json.hash; that.hash = json.hash;
that.read = json.read_signature ? true : false; that.read = json.read_signature ? true : false;
that.message = json.reference && messagePrefixes[json.reference.index] ? that.message = json.code && (json.reference && messagePrefixes[json.reference.index] ?
messagePrefixes[json.reference.index] + json.code : messagePrefixes[json.reference.index] + json.code :
'EVENT.' + json.code; 'EVENT.' + json.code) || json.message;
that.params = json.params; that.params = json.params;
if (markAsReadCallback && (typeof markAsReadCallback === "function") ) { if (markAsReadCallback && (typeof markAsReadCallback === "function") ) {
......
...@@ -118,7 +118,7 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es ...@@ -118,7 +118,7 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es
// Add some wallet events as notifications // Add some wallet events as notifications
var time = csHttp.date.now() - filterTranslations.MEDIAN_TIME_OFFSET; var time = csHttp.date.now() - filterTranslations.MEDIAN_TIME_OFFSET;
var result = (wallet.data.events || []).reduce(function(res, event) { var result = (wallet.data.events || []).reduce(function(res, event) {
if (event.type != "warn" && event.type != "error") return res; // Keep only warn and error events if (event.type !== "warn" && event.type !== "error") return res; // Keep only warn and error events
var notification = new EsNotification({}, function(self) { var notification = new EsNotification({}, function(self) {
if (!self.read) { if (!self.read) {
self.read = true; self.read = true;
...@@ -127,12 +127,12 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es ...@@ -127,12 +127,12 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es
} }
} }
}); });
notification.id=event.code; notification.id= event.code;
notification.time= time;
notification.read = false; notification.read = false;
notification.state = 'app.view_wallet'; notification.state = 'app.view_wallet';
notification.avatarIcon = 'ion-alert-circled'; notification.avatarIcon = 'ion-alert-circled';
notification.icon = 'ion-alert-circled assertive'; notification.icon = 'ion-alert-circled assertive';
notification.time = time;
notification.message = event.message; notification.message = event.message;
notification.messageParams = event.messageParams; notification.messageParams = event.messageParams;
return res.concat(notification); return res.concat(notification);
...@@ -200,6 +200,7 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es ...@@ -200,6 +200,7 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es
} }
var notification = new EsNotification(event, markNotificationAsRead); var notification = new EsNotification(event, markNotificationAsRead);
notification.id = event.id || notification.id;
// Extend the notification entity // Extend the notification entity
return csWot.extendAll([notification]) return csWot.extendAll([notification])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment