Skip to content

Commit

Permalink
fix: Improve Unregistered Notification UX
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegoO committed Jun 4, 2024
1 parent 317cba2 commit 27a4f3f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ public interface INotificationRegistrar
NotificationBuilder Notification<TNotification>() where TNotification : Notification;
NotificationBuilder RegisterNotification<TNotification>(Func<Notification> factory = null) where TNotification : Notification;
NotificationBuilder OverrideNotificationType<TOldNotificationType, TNewNotificationType>(Func<Notification> factory = null) where TOldNotificationType : Notification where TNewNotificationType : Notification;
void UnregisterNotification<TNotification>() where TNotification : Notification;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using VirtoCommerce.NotificationsModule.Core.Model;
using VirtoCommerce.NotificationsModule.Core.Services;
using VirtoCommerce.NotificationsModule.Data.Repositories;
using VirtoCommerce.Platform.Core.Common;

namespace VirtoCommerce.NotificationsModule.Data.Services
Expand Down Expand Up @@ -49,17 +47,5 @@ public NotificationBuilder OverrideNotificationType<TOldNotificationType, TNewNo

return builder;
}

public void UnregisterNotification<TNotification>() where TNotification : Notification
{
var repositoryFactory = _serviceProvider.GetService<Func<INotificationRepository>>();
using var repository = repositoryFactory();
var notificationType = nameof(TNotification);
foreach (var item in repository.Notifications.Where(n => n.Type == notificationType))
{
repository.Remove(item);
}
repository.UnitOfWork.Commit();
}
}
}

0 comments on commit 27a4f3f

Please sign in to comment.