mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Mark read and unread
This commit is contained in:
@@ -74,5 +74,20 @@ namespace BTCPayServer.Controllers
|
|||||||
|
|
||||||
return RedirectToAction(nameof(Index));
|
return RedirectToAction(nameof(Index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IActionResult> FlipRead(string id)
|
||||||
|
{
|
||||||
|
// TODO: Refactor
|
||||||
|
var claimWithId = User.Claims.SingleOrDefault(a => a.Type == ClaimTypes.NameIdentifier);
|
||||||
|
if (claimWithId == null)
|
||||||
|
return RedirectToAction("Index", "Home");
|
||||||
|
|
||||||
|
var notif = _db.Notifications.SingleOrDefault(a => a.Id == id && a.ApplicationUserId == claimWithId.Value);
|
||||||
|
notif.Seen = !notif.Seen;
|
||||||
|
await _db.SaveChangesAsync();
|
||||||
|
|
||||||
|
return RedirectToAction(nameof(Index));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ namespace BTCPayServer.Models.NotificationViewModels
|
|||||||
public DateTimeOffset Created { get; set; }
|
public DateTimeOffset Created { get; set; }
|
||||||
public string Body { get; set; }
|
public string Body { get; set; }
|
||||||
public string ActionLink { get; set; }
|
public string ActionLink { get; set; }
|
||||||
|
public bool Seen { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class NotificationViewModelExt
|
public static class NotificationViewModelExt
|
||||||
@@ -36,7 +37,8 @@ namespace BTCPayServer.Models.NotificationViewModels
|
|||||||
Id = data.Id,
|
Id = data.Id,
|
||||||
Created = data.Created,
|
Created = data.Created,
|
||||||
Body = $"New version {casted.Version} released!",
|
Body = $"New version {casted.Version} released!",
|
||||||
ActionLink = "https://github.com/btcpayserver/btcpayserver/releases/tag/v" + casted.Version
|
ActionLink = "https://github.com/btcpayserver/btcpayserver/releases/tag/v" + casted.Version,
|
||||||
|
Seen = data.Seen
|
||||||
};
|
};
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
|
|||||||
@@ -40,9 +40,11 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var item in Model.Items)
|
@foreach (var item in Model.Items)
|
||||||
{
|
{
|
||||||
|
@* TODO: Click on td to mark notification read through JavaScript magic *@
|
||||||
|
@* TODO: Multiselect akin to Gmail *@
|
||||||
<tr>
|
<tr>
|
||||||
<td>@item.Created.ToBrowserDate()</td>
|
<td class="cursor-pointer @(item.Seen ? "": "font-weight-bold")">@item.Created.ToBrowserDate()</td>
|
||||||
<td>@item.Body</td>
|
<td class="cursor-pointer @(item.Seen ? "": "font-weight-bold")">@item.Body</td>
|
||||||
<td>
|
<td>
|
||||||
@if (!String.IsNullOrEmpty(item.ActionLink))
|
@if (!String.IsNullOrEmpty(item.ActionLink))
|
||||||
{
|
{
|
||||||
@@ -54,7 +56,16 @@
|
|||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a asp-action="Delete" asp-route-id="@item.Id"><span class="fa fa-trash"></span></a>
|
@if (item.Seen)
|
||||||
|
{
|
||||||
|
<a asp-action="FlipRead" asp-route-id="@item.Id"><span class="fa fa-envelope-o" title="Mark Unread"></span></a>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<a asp-action="FlipRead" asp-route-id="@item.Id"><span class="fa fa-envelope-open-o" title="Mark Read"></span></a>
|
||||||
|
}
|
||||||
|
|
||||||
|
<a asp-action="Delete" asp-route-id="@item.Id"><span class="fa fa-trash-o" title="Delete"></span></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user