mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-20 13:34:37 +01:00
Add "Mark all as seen" button to notification dropdown (#2101)
This commit is contained in:
parent
0d144d088e
commit
b1e9c005b7
3 changed files with 19 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
|||
@inject UserManager<ApplicationUser> UserManager
|
||||
@inject CssThemeManager CssThemeManager
|
||||
@using BTCPayServer.HostedServices
|
||||
@using Microsoft.AspNetCore.Http.Extensions
|
||||
@model BTCPayServer.Components.NotificationsDropdown.NotificationSummaryViewModel
|
||||
|
||||
@if (Model.UnseenCount > 0)
|
||||
|
@ -24,6 +25,9 @@
|
|||
</a>
|
||||
}
|
||||
<a class="dropdown-item text-secondary" asp-controller="Notifications" asp-action="Index">See All</a>
|
||||
<form asp-controller="Notifications" asp-action="MarkAllAsSeen" asp-route-returnUrl="@Context.Request.GetDisplayUrl()" method="post">
|
||||
<button class="dropdown-item text-secondary" type="submit"><i class="fa fa-eye"></i> Mark all as seen</button>
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
}
|
||||
|
|
|
@ -206,6 +206,17 @@ namespace BTCPayServer.Controllers
|
|||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> MarkAllAsSeen(string returnUrl)
|
||||
{
|
||||
if (!ValidUserClaim(out var userId))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
await _notificationManager.ToggleSeen(new NotificationsQuery() {Seen = false, UserId = userId}, true);
|
||||
return Redirect(returnUrl);
|
||||
}
|
||||
|
||||
private bool ValidUserClaim(out string userId)
|
||||
{
|
||||
userId = _userManager.GetUserId(User);
|
||||
|
|
|
@ -13,6 +13,10 @@ namespace BTCPayServer.Services.Notifications
|
|||
public class UserNotificationsUpdatedEvent
|
||||
{
|
||||
public string UserId { get; set; }
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
public class NotificationSender
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue