From 7f6019e492d50e4d07498b17dac0bf437fdd66ec Mon Sep 17 00:00:00 2001 From: zeripath Date: Sat, 17 Jul 2021 18:05:59 +0100 Subject: [PATCH] Update notification table with only latest data (#16445) (#16469) When marking notifications read the results may be returned out of order or be delayed. This PR sends a sequence number to gitea so that the browser can ensure that only the results of the latest notification change are shown. Signed-off-by: Andrew Thornton --- routers/web/user/notification.go | 2 ++ .../user/notification/notification_div.tmpl | 2 +- web_src/js/features/notification.js | 16 ++++++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/routers/web/user/notification.go b/routers/web/user/notification.go index 523e945db9bb..851af5d64792 100644 --- a/routers/web/user/notification.go +++ b/routers/web/user/notification.go @@ -50,6 +50,7 @@ func Notifications(c *context.Context) { return } if c.QueryBool("div-only") { + c.Data["SequenceNumber"] = c.Query("sequence-number") c.HTML(http.StatusOK, tplNotificationDiv) return } @@ -175,6 +176,7 @@ func NotificationStatusPost(c *context.Context) { return } c.Data["Link"] = setting.AppURL + "notifications" + c.Data["SequenceNumber"] = c.Req.PostFormValue("sequence-number") c.HTML(http.StatusOK, tplNotificationDiv) } diff --git a/templates/user/notification/notification_div.tmpl b/templates/user/notification/notification_div.tmpl index e7327d34bbe9..8976e1fda4a0 100644 --- a/templates/user/notification/notification_div.tmpl +++ b/templates/user/notification/notification_div.tmpl @@ -1,4 +1,4 @@ -
+

{{.i18n.Tr "notification.notifications"}}