Commit 637141a4 by benjaminapetersen

Improve notification id

- _.uniqueId() is not sufficient since the ID is used to persist some data
  for notifications via session storage.  The id generated starts at a low
  number & increments w/o randomness.
- Using _.uniqueId() along with Date.now() adds a random value that cannot
  be replicated across sessions/refresh
parent cdb2f37c
......@@ -2149,7 +2149,7 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
};
var addNotification = function (notification) {
notification.id = notification.id || _.uniqueId('notification-');
notification.id = notification.id || _.uniqueId('notification-') + Date.now();
notification.timestamp = new Date().toISOString();
if (isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification)) {
return;
......
......@@ -5720,7 +5720,7 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
};
var addNotification = function (notification) {
notification.id = notification.id || _.uniqueId('notification-');
notification.id = notification.id || _.uniqueId('notification-') + Date.now();
notification.timestamp = new Date().toISOString();
if (isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification)) {
return;
......
......@@ -2415,7 +2415,7 @@ this.dismissDelay = 8e3, this.autoDismissTypes = [ "info", "success" ], this.$ge
var notifications = [], dismissDelay = this.dismissDelay, autoDismissTypes = this.autoDismissTypes, notificationHiddenKey = function(notificationID, namespace) {
return namespace ? "hide/notification/" + namespace + "/" + notificationID :"hide/notification/" + notificationID;
}, addNotification = function(notification) {
notification.id = notification.id || _.uniqueId("notification-"), notification.timestamp = new Date().toISOString(), isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification) || (notifications.push(notification), $rootScope.$emit("NotificationsService.onNotificationAdded", notification));
notification.id = notification.id || _.uniqueId("notification-") + Date.now(), notification.timestamp = new Date().toISOString(), isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification) || (notifications.push(notification), $rootScope.$emit("NotificationsService.onNotificationAdded", notification));
}, hideNotification = function(notificationID) {
notificationID && _.each(notifications, function(notification) {
notification.id === notificationID && (notification.hidden = !0);
......
......@@ -18,7 +18,7 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
};
var addNotification = function (notification) {
notification.id = notification.id || _.uniqueId('notification-');
notification.id = notification.id || _.uniqueId('notification-') + Date.now();
notification.timestamp = new Date().toISOString();
if (isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification)) {
return;
......
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