mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Refresh UI notifications automatically on update (#1680)
* Refresh UI notifications automatically on update * make notif timeago live * pass cancellation token * Update InvoiceEventData.cs
This commit is contained in:
@@ -20,15 +20,17 @@ namespace BTCPayServer.Services.Notifications
|
||||
private readonly ApplicationDbContextFactory _factory;
|
||||
private readonly UserManager<ApplicationUser> _userManager;
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
private readonly EventAggregator _eventAggregator;
|
||||
private readonly Dictionary<string, INotificationHandler> _handlersByNotificationType;
|
||||
private readonly Dictionary<Type, INotificationHandler> _handlersByBlobType;
|
||||
|
||||
public NotificationManager(ApplicationDbContextFactory factory, UserManager<ApplicationUser> userManager,
|
||||
IMemoryCache memoryCache, IEnumerable<INotificationHandler> handlers)
|
||||
IMemoryCache memoryCache, IEnumerable<INotificationHandler> handlers, EventAggregator eventAggregator)
|
||||
{
|
||||
_factory = factory;
|
||||
_userManager = userManager;
|
||||
_memoryCache = memoryCache;
|
||||
_eventAggregator = eventAggregator;
|
||||
_handlersByNotificationType = handlers.ToDictionary(h => h.NotificationType);
|
||||
_handlersByBlobType = handlers.ToDictionary(h => h.NotificationBlobType);
|
||||
}
|
||||
@@ -52,6 +54,8 @@ namespace BTCPayServer.Services.Notifications
|
||||
public void InvalidateNotificationCache(string userId)
|
||||
{
|
||||
_memoryCache.Remove(GetNotificationsCacheId(userId));
|
||||
|
||||
_eventAggregator.Publish(new UserNotificationsUpdatedEvent() {UserId = userId});
|
||||
}
|
||||
|
||||
private static string GetNotificationsCacheId(string userId)
|
||||
|
||||
Reference in New Issue
Block a user