From 51e86e5aee4b9a10fcb762be56cc2196663a6f7c Mon Sep 17 00:00:00 2001 From: zeripath Date: Sat, 17 Jul 2021 17:18:10 +0100 Subject: [PATCH] Update notification table with only latest data (#16445) 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 Co-authored-by: 6543 <6543@obermui.de> --- 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 523e945db9bbb..851af5d647927 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 e7327d34bbe99..8976e1fda4a00 100644 --- a/templates/user/notification/notification_div.tmpl +++ b/templates/user/notification/notification_div.tmpl @@ -1,4 +1,4 @@ -
+

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