2022-01-13 09:08:15 +01:00
|
|
|
using System.Linq;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using BTCPayServer.Services.Notifications;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
namespace BTCPayServer.Components.Notifications
|
|
|
|
{
|
|
|
|
public class Notifications : ViewComponent
|
|
|
|
{
|
|
|
|
private readonly NotificationManager _notificationManager;
|
|
|
|
|
|
|
|
private static readonly string[] _views = { "List", "Dropdown", "Recent" };
|
|
|
|
|
|
|
|
public Notifications(NotificationManager notificationManager)
|
|
|
|
{
|
|
|
|
_notificationManager = notificationManager;
|
|
|
|
}
|
|
|
|
|
2022-06-09 18:25:05 +02:00
|
|
|
public async Task<IViewComponentResult> InvokeAsync(string appearance, string returnUrl)
|
2022-01-13 09:08:15 +01:00
|
|
|
{
|
|
|
|
var vm = await _notificationManager.GetSummaryNotifications(UserClaimsPrincipal);
|
2022-06-09 18:25:05 +02:00
|
|
|
vm.ReturnUrl = returnUrl;
|
2022-01-13 09:08:15 +01:00
|
|
|
var viewName = _views.Contains(appearance) ? appearance : _views[0];
|
|
|
|
return View(viewName, vm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|