Skip to content

Commit

Permalink
combined if statements
Browse files Browse the repository at this point in the history
  • Loading branch information
chiragkrishna authored Sep 7, 2024
1 parent 8cc9f52 commit 23abedd
Showing 1 changed file with 20 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,31 @@ public async Task ProcessItemsAsync()
var webhookSender = scope.ServiceProvider.GetRequiredService<IWebhookSender>();
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 _);
}
}
}
Expand All @@ -95,4 +92,4 @@ public void AddItem(BaseItem item)
_deletedItems.TryAdd(item.Id, item);
_logger.LogDebug("Queued {ItemName} for notification", item.Name);
}
}
}

0 comments on commit 23abedd

Please sign in to comment.