{{.i18n.Tr "notification.notifications"}}
diff --git a/web_src/js/features/notification.js b/web_src/js/features/notification.js
index 4fa2d3c29af31..d964ffa3052d8 100644
--- a/web_src/js/features/notification.js
+++ b/web_src/js/features/notification.js
@@ -1,5 +1,7 @@
const {AppSubUrl, csrf, NotificationSettings} = window.config;
+let notificationSequenceNumber = 0;
+
export function initNotificationsTable() {
$('#notification_table .button').on('click', async function () {
const data = await updateNotification(
@@ -10,8 +12,10 @@ export function initNotificationsTable() {
$(this).data('notification-id'),
);
- $('#notification_div').replaceWith(data);
- initNotificationsTable();
+ if ($(data).data('sequence-number') === notificationSequenceNumber) {
+ $('#notification_div').replaceWith(data);
+ initNotificationsTable();
+ }
await updateNotificationCount();
return false;
@@ -139,10 +143,13 @@ async function updateNotificationTable() {
url: `${AppSubUrl}/notifications?${notificationDiv.data('params')}`,
data: {
'div-only': true,
+ 'sequence-number': ++notificationSequenceNumber,
}
});
- notificationDiv.replaceWith(data);
- initNotificationsTable();
+ if ($(data).data('sequence-number') === notificationSequenceNumber) {
+ notificationDiv.replaceWith(data);
+ initNotificationsTable();
+ }
}
}
@@ -182,6 +189,7 @@ async function updateNotification(url, status, page, q, notificationID) {
page,
q,
noredirect: true,
+ 'sequence-number': ++notificationSequenceNumber,
},
});
}