mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-23 06:35:13 +01:00
Fixes the return URL for the case in which the dropdown content got replaced after a notification update: As the refresh request is done via AJAX, the return URL previously was `/notifications/getnotificationdropdownui` (the `Context.Request.GetCurrentPathWithQueryString()` value of the AJAX action). We need to pass in the URL of the actual current page as the return URL.
27 lines
905 B
C#
27 lines
905 B
C#
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;
|
|
}
|
|
|
|
public async Task<IViewComponentResult> InvokeAsync(string appearance, string returnUrl)
|
|
{
|
|
var vm = await _notificationManager.GetSummaryNotifications(UserClaimsPrincipal);
|
|
vm.ReturnUrl = returnUrl;
|
|
var viewName = _views.Contains(appearance) ? appearance : _views[0];
|
|
return View(viewName, vm);
|
|
}
|
|
}
|
|
}
|