]> source.dussan.org Git - gitea.git/commitdiff
Fix notification list bugs (#25781)
authorwxiaoguang <wxiaoguang@gmail.com>
Sun, 9 Jul 2023 18:42:31 +0000 (02:42 +0800)
committerGitHub <noreply@github.com>
Sun, 9 Jul 2023 18:42:31 +0000 (18:42 +0000)
Fix #25627

1. `ctx.Data["Link"]` should use relative URL but not AppURL
2. The `data-params` is incorrect because it doesn't contain "page". JS
can simply use "window.location.search" to construct the AJAX URL
3. The `data-xxx` and `id` in notification_subscriptions.tmpl were
copied&pasted, they don't have affect.

routers/web/user/notification.go
templates/user/notification/notification_div.tmpl
templates/user/notification/notification_subscriptions.tmpl
web_src/js/features/notification.js

index e0aa92879fcc421a2dd8f82ba12944e39593c765..cae12f4126775bf913f5048e33781c4995da5e45 100644 (file)
@@ -186,7 +186,7 @@ func NotificationStatusPost(ctx *context.Context) {
        if ctx.Written() {
                return
        }
-       ctx.Data["Link"] = setting.AppURL + "notifications"
+       ctx.Data["Link"] = setting.AppSubURL + "/notifications"
        ctx.Data["SequenceNumber"] = ctx.Req.PostFormValue("sequence-number")
 
        ctx.HTML(http.StatusOK, tplNotificationDiv)
index a8c070d7642d569a37dc3a564659b233441faa90..3cc9d31d52c3aaaa8071084a9c8c02d1e2bb52eb 100644 (file)
@@ -1,4 +1,4 @@
-<div role="main" aria-label="{{.Title}}" class="page-content user notification" id="notification_div" data-params="{{.Page.GetParams}}" data-sequence-number="{{.SequenceNumber}}">
+<div role="main" aria-label="{{.Title}}" class="page-content user notification" id="notification_div" data-sequence-number="{{.SequenceNumber}}">
        <div class="ui container">
                {{$notificationUnreadCount := call .NotificationUnreadCount}}
                <div class="gt-df gt-ac gt-sb gt-mb-4">
index 40586595bb446c60ae0a82f23086e2c6c4c5782e..b5119394478c34a523571a7eecf5cc6ee0addb7d 100644 (file)
@@ -1,5 +1,5 @@
 {{template "base/head" .}}
-<div role="main" aria-label="{{.Title}}" class="page-content user notification" id="notification_subscriptions" data-params="{{.Page.GetParams}}" data-sequence-number="{{.SequenceNumber}}">
+<div role="main" aria-label="{{.Title}}" class="page-content user notification">
        <div class="ui container">
                <div class="ui top attached tabular menu">
                        <a href="{{AppSubUrl}}/notifications/subscriptions" class="{{if eq .Status 1}}active {{end}}item">
index 0c24d36e5664bbef9da18fcf849847a3271952cb..4dcf02d2dca900208a6e1d353709c38fae6e8354 100644 (file)
@@ -165,7 +165,7 @@ async function updateNotificationTable() {
   if (notificationDiv.length > 0) {
     const data = await $.ajax({
       type: 'GET',
-      url: `${appSubUrl}/notifications?${notificationDiv.data('params')}`,
+      url: `${appSubUrl}/notifications${window.location.search}`,
       data: {
         'div-only': true,
         'sequence-number': ++notificationSequenceNumber,