Skip to content

Commit 65071d5

Browse files
author
Anton Bracke
committed
fix
1 parent 8a63806 commit 65071d5

File tree

2 files changed

+31
-42
lines changed

2 files changed

+31
-42
lines changed

routers/web/user/notification.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ func NotificationStatusPost(ctx *context.Context) {
180180
ctx.Redirect(url, http.StatusSeeOther)
181181
}
182182

183+
// convert the action to the displayed list
184+
if statusStr == "unread" {
185+
ctx.SetFormString("q", "read")
186+
} else {
187+
ctx.SetFormString("q", "unread")
188+
}
183189
getNotifications(ctx)
184190
if ctx.Written() {
185191
return

templates/user/notification/notification_div.tmpl

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -69,51 +69,34 @@
6969
</div>
7070
<div class="notifications-buttons tw-items-center tw-justify-end tw-gap-1 tw-px-1">
7171
{{if ne .Status 3}}
72-
<form action="{{AppSubUrl}}/notifications/status" method="post">
73-
{{$.CsrfTokenHtml}}
74-
<input type="hidden" name="notification_id" value="{{.ID}}">
75-
<input type="hidden" name="status" value="pinned">
76-
<button type="button" class="btn interact-bg tw-p-2" title="{{ctx.Locale.Tr "notification.pin"}}"
77-
hx-post="{{AppSubUrl}}/notifications/status"
78-
hx-target="#notification_div"
79-
hx-swap="outerHTML"
80-
hx-vals='{"notification_id": "{{.ID}}", "status": "pinned", "page": "{{$.Page.Paginater.Current}}", "_csrf": "{{$.CsrfToken}}"}'
81-
{{if eq .Status 3}}disabled{{end}}
82-
>
83-
{{svg "octicon-pin"}}
84-
</button>
85-
</form>
72+
<button type="button" class="btn interact-bg tw-p-2" title="{{ctx.Locale.Tr "notification.pin"}}"
73+
hx-post="{{AppSubUrl}}/notifications/status"
74+
hx-target="#notification_div"
75+
hx-swap="outerHTML"
76+
hx-vals='{"notification_id": "{{.ID}}", "status": "pinned", "page": "{{$.Page.Paginater.Current}}", "_csrf": "{{$.CsrfToken}}", "noredirect": "true" }'
77+
{{if eq .Status 3}}disabled{{end}}
78+
>
79+
{{svg "octicon-pin"}}
80+
</button>
8681
{{end}}
8782
{{if or (eq .Status 1) (eq .Status 3)}}
88-
<form action="{{AppSubUrl}}/notifications/status" method="post">
89-
{{$.CsrfTokenHtml}}
90-
<input type="hidden" name="notification_id" value="{{.ID}}">
91-
<input type="hidden" name="status" value="read">
92-
<input type="hidden" name="page" value="{{$.Page.Paginater.Current}}">
93-
<button type="button" class="btn interact-bg tw-p-2" title="{{ctx.Locale.Tr "notification.mark_as_read"}}"
94-
hx-post="{{AppSubUrl}}/notifications/status"
95-
hx-target="#notification_div"
96-
hx-swap="outerHTML"
97-
hx-vals='{"notification_id": "{{.ID}}", "status": "read", "page": "{{$.Page.Paginater.Current}}", "_csrf": "{{$.CsrfToken}}"}'
98-
>
99-
{{svg "octicon-check"}}
100-
</button>
101-
</form>
83+
<button type="button" class="btn interact-bg tw-p-2" title="{{ctx.Locale.Tr "notification.mark_as_read"}}"
84+
hx-post="{{AppSubUrl}}/notifications/status"
85+
hx-target="#notification_div"
86+
hx-swap="outerHTML"
87+
hx-vals='{"notification_id": "{{.ID}}", "status": "read", "page": "{{$.Page.Paginater.Current}}", "_csrf": "{{$.CsrfToken}}", "noredirect": "true"}'
88+
>
89+
{{svg "octicon-check"}} 123
90+
</button>
10291
{{else if eq .Status 2}}
103-
<form action="{{AppSubUrl}}/notifications/status" method="post">
104-
{{$.CsrfTokenHtml}}
105-
<input type="hidden" name="notification_id" value="{{.ID}}">
106-
<input type="hidden" name="status" value="unread">
107-
<input type="hidden" name="page" value="{{$.Page.Paginater.Current}}">
108-
<button type="button" class="btn interact-bg tw-p-2" title="{{ctx.Locale.Tr "notification.mark_as_unread"}}"
109-
hx-post="{{AppSubUrl}}/notifications/status"
110-
hx-target="#notification_div"
111-
hx-swap="outerHTML"
112-
hx-vals='{"notification_id": "{{.ID}}", "status": "unread", "page": "{{$.Page.Paginater.Current}}", "_csrf": "{{$.CsrfToken}}"}'
113-
>
114-
{{svg "octicon-bell"}}
115-
</button>
116-
</form>
92+
<button type="button" class="btn interact-bg tw-p-2" title="{{ctx.Locale.Tr "notification.mark_as_unread"}}"
93+
hx-post="{{AppSubUrl}}/notifications/status"
94+
hx-target="#notification_div"
95+
hx-swap="outerHTML"
96+
hx-vals='{"notification_id": "{{.ID}}", "status": "unread", "page": "{{$.Page.Paginater.Current}}", "_csrf": "{{$.CsrfToken}}", "noredirect": "true"}'
97+
>
98+
{{svg "octicon-bell"}}
99+
</button>
117100
{{end}}
118101
</div>
119102
</div>

0 commit comments

Comments
 (0)