From 23abedd582a2a9f0386685d8ff06687d700c36b0 Mon Sep 17 00:00:00 2001 From: chiragkrishna Date: Sun, 8 Sep 2024 00:50:43 +0530 Subject: [PATCH] combined if statements --- .../ItemDeletedNotifier/ItemDeletedManager.cs | 43 +++++++++---------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/Jellyfin.Plugin.Webhook/Notifiers/ItemDeletedNotifier/ItemDeletedManager.cs b/Jellyfin.Plugin.Webhook/Notifiers/ItemDeletedNotifier/ItemDeletedManager.cs index 1812271..073a7ec 100644 --- a/Jellyfin.Plugin.Webhook/Notifiers/ItemDeletedNotifier/ItemDeletedManager.cs +++ b/Jellyfin.Plugin.Webhook/Notifiers/ItemDeletedNotifier/ItemDeletedManager.cs @@ -53,34 +53,31 @@ public async Task ProcessItemsAsync() var webhookSender = scope.ServiceProvider.GetRequiredService(); foreach (var (key, container) in currentItems) { - if (_deletedItems.TryGetValue(key, out var item)) + if (_deletedItems.TryGetValue(key, out var item) && item != null) { - if (item != null) + // Skip notification if item type is Studio + if (container.ItemType == "Studio") { - // Skip notification if item type is Studio - if (container.ItemType == "Studio") - { - _logger.LogDebug("Skipping notification for item type Studio"); - _itemProcessQueue.TryRemove(key, out _); - _deletedItems.TryRemove(key, out _); - continue; - } + _logger.LogDebug("Skipping notification for item type Studio"); + _itemProcessQueue.TryRemove(key, out _); + _deletedItems.TryRemove(key, out _); + continue; + } - _logger.LogDebug("Notifying for {ItemName}", container.Name); + _logger.LogDebug("Notifying for {ItemName}", container.Name); - // Send notification to each configured destination. - var dataObject = DataObjectHelpers - .GetBaseDataObject(_applicationHost, NotificationType.ItemDeleted) - .AddBaseItemData(item); + // Send notification to each configured destination. + var dataObject = DataObjectHelpers + .GetBaseDataObject(_applicationHost, NotificationType.ItemDeleted) + .AddBaseItemData(item); - var itemType = Type.GetType($"MediaBrowser.Controller.Entities.{container.ItemType}"); - await webhookSender.SendNotification(NotificationType.ItemDeleted, dataObject, itemType) - .ConfigureAwait(false); + var itemType = Type.GetType($"MediaBrowser.Controller.Entities.{container.ItemType}"); + await webhookSender.SendNotification(NotificationType.ItemDeleted, dataObject, itemType) + .ConfigureAwait(false); - // Remove item from queue. - _itemProcessQueue.TryRemove(key, out _); - _deletedItems.TryRemove(key, out _); - } + // Remove item from queue. + _itemProcessQueue.TryRemove(key, out _); + _deletedItems.TryRemove(key, out _); } } } @@ -95,4 +92,4 @@ public void AddItem(BaseItem item) _deletedItems.TryAdd(item.Id, item); _logger.LogDebug("Queued {ItemName} for notification", item.Name); } -} \ No newline at end of file +}