return
}
if c.QueryBool("div-only") {
+ c.Data["SequenceNumber"] = c.Query("sequence-number")
c.HTML(http.StatusOK, tplNotificationDiv)
return
}
return
}
c.Data["Link"] = setting.AppURL + "notifications"
+ c.Data["SequenceNumber"] = c.Req.PostFormValue("sequence-number")
c.HTML(http.StatusOK, tplNotificationDiv)
}
-<div class="page-content user notification" id="notification_div" data-params="{{.Page.GetParams}}">
+<div class="page-content user notification" id="notification_div" data-params="{{.Page.GetParams}}" data-sequence-number="{{.SequenceNumber}}">
<div class="ui container">
<h1 class="ui dividing header">{{.i18n.Tr "notification.notifications"}}</h1>
<div class="ui top attached tabular menu">
const {AppSubUrl, csrf, NotificationSettings} = window.config;
+let notificationSequenceNumber = 0;
+
export function initNotificationsTable() {
$('#notification_table .button').on('click', async function () {
const data = await updateNotification(
$(this).data('notification-id'),
);
- $('#notification_div').replaceWith(data);
- initNotificationsTable();
+ if ($(data).data('sequence-number') === notificationSequenceNumber) {
+ $('#notification_div').replaceWith(data);
+ initNotificationsTable();
+ }
await updateNotificationCount();
return false;
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();
+ }
}
}
page,
q,
noredirect: true,
+ 'sequence-number': ++notificationSequenceNumber,
},
});
}