Easy comment thread unsubscribe links in Notifications

This commit is contained in:
Noah Petherbridge 2024-08-07 22:15:47 -07:00
parent f1cf1bd958
commit 01c38c5c21
3 changed files with 30 additions and 8 deletions

View File

@ -81,7 +81,7 @@ func Subscription() http.HandlerFunc {
if subscribe { if subscribe {
session.Flash(w, r, "You will now be notified about comments on this page.") session.Flash(w, r, "You will now be notified about comments on this page.")
} else { } else {
session.Flash(w, r, "You will no longer be notified about new comments on this page.") session.Flash(w, r, "You will no longer be notified about new comments on that thread.")
} }
} }
} }

View File

@ -208,4 +208,14 @@ img {
.nonshy-htsignup { .nonshy-htsignup {
display: none; display: none;
}
/* Dashboard notification page styles */
.nonshy-notification-row {
position: relative;
}
.nonshy-notif-delete-button {
position: absolute;
top: 4px;
right: 4px;
} }

View File

@ -480,6 +480,14 @@
{{$Body := $Root.NotifMap.Get .ID}} {{$Body := $Root.NotifMap.Get .ID}}
<tr> <tr>
<td class="nonshy-notification-row" data-notification-id="{{.ID}}"> <td class="nonshy-notification-row" data-notification-id="{{.ID}}">
<!-- Delete button for just this notification -->
<button type="button"
class="button is-danger px-2 py-1 is-small nonshy-notif-delete-button"
data-notification-id="{{.ID}}"
title="Remove this notification from your feed">
<i class="fa fa-xmark mr"></i>
</button>
<div class="columns"> <div class="columns">
<div class="column is-narrow has-text-centered"> <div class="column is-narrow has-text-centered">
{{if not .Read}} {{if not .Read}}
@ -655,13 +663,17 @@
<small title="{{.CreatedAt.Format "2006-01-02 15:04:05"}}"> <small title="{{.CreatedAt.Format "2006-01-02 15:04:05"}}">
{{SincePrettyCoarse .CreatedAt}} ago. {{SincePrettyCoarse .CreatedAt}} ago.
<!-- Delete button for just this notification --> <!-- Contextual "Unsubscribe" buttons -->
<button type="button" {{if or (eq .Type "also_posted") (eq .Type "also_comment")}}
class="button is-danger is-light is-small nonshy-notif-delete-button" <small>
data-notification-id="{{.ID}}" <a href="/comments/subscription?table_name={{.TableName}}&table_id={{.TableID}}&next={{UrlEncode $Root.Request.URL.String}}&subscribe=false"
title="Remove this notification from your feed"> class="has-text-warning is-small"
<i class="fa fa-xmark mr-1"></i> Clear title="Turn off notifications about this thread"
</button> onclick="return confirm('Do you want to turn off notifications about this comment thread?')">
<i class="fa fa-microphone-slash mr-1"></i> Mute this thread
</a>
</small>
{{end}}
</small> </small>
</div> </div>