mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-29 04:04:47 +03:00
fixes #223 - New Content Localhost Popups Repeat 'Old' 'New Content' on Media Changes
This commit is contained in:
@@ -69,24 +69,20 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <value>The item repository.</value>
|
||||
public IItemRepository ItemRepository { get; set; }
|
||||
|
||||
#region LibraryChanged Event
|
||||
/// <summary>
|
||||
/// Fires whenever any validation routine adds or removes items. The added and removed items are properties of the args.
|
||||
/// *** Will fire asynchronously. ***
|
||||
/// Occurs when [item added].
|
||||
/// </summary>
|
||||
public event EventHandler<ChildrenChangedEventArgs> LibraryChanged;
|
||||
public event EventHandler<ItemChangeEventArgs> ItemAdded;
|
||||
|
||||
/// <summary>
|
||||
/// Reports the library changed.
|
||||
/// Occurs when [item updated].
|
||||
/// </summary>
|
||||
/// <param name="args">The <see cref="ChildrenChangedEventArgs" /> instance containing the event data.</param>
|
||||
public void ReportLibraryChanged(ChildrenChangedEventArgs args)
|
||||
{
|
||||
UpdateLibraryCache(args);
|
||||
public event EventHandler<ItemChangeEventArgs> ItemUpdated;
|
||||
|
||||
EventHelper.FireEventIfNotNull(LibraryChanged, this, args, _logger);
|
||||
}
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Occurs when [item removed].
|
||||
/// </summary>
|
||||
public event EventHandler<ItemChangeEventArgs> ItemRemoved;
|
||||
|
||||
/// <summary>
|
||||
/// The _logger
|
||||
@@ -302,25 +298,6 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
return new ConcurrentDictionary<Guid, BaseItem>(items.ToDictionary(i => i.Id));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the library cache.
|
||||
/// </summary>
|
||||
/// <param name="args">The <see cref="ChildrenChangedEventArgs"/> instance containing the event data.</param>
|
||||
private void UpdateLibraryCache(ChildrenChangedEventArgs args)
|
||||
{
|
||||
UpdateItemInLibraryCache(args.Folder);
|
||||
|
||||
foreach (var item in args.ItemsAdded)
|
||||
{
|
||||
UpdateItemInLibraryCache(item);
|
||||
}
|
||||
|
||||
foreach (var item in args.ItemsUpdated)
|
||||
{
|
||||
UpdateItemInLibraryCache(item);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the item in library cache.
|
||||
/// </summary>
|
||||
@@ -1069,13 +1046,61 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
return comparer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the item.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
public async Task CreateItem(BaseItem item, CancellationToken cancellationToken)
|
||||
{
|
||||
await SaveItem(item, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
UpdateItemInLibraryCache(item);
|
||||
|
||||
if (ItemAdded != null)
|
||||
{
|
||||
ItemAdded(this, new ItemChangeEventArgs { Item = item });
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the item.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
public async Task UpdateItem(BaseItem item, CancellationToken cancellationToken)
|
||||
{
|
||||
await SaveItem(item, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
UpdateItemInLibraryCache(item);
|
||||
|
||||
if (ItemUpdated != null)
|
||||
{
|
||||
ItemUpdated(this, new ItemChangeEventArgs { Item = item });
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reports the item removed.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
public void ReportItemRemoved(BaseItem item)
|
||||
{
|
||||
if (ItemRemoved != null)
|
||||
{
|
||||
ItemRemoved(this, new ItemChangeEventArgs { Item = item });
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the item.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
public Task SaveItem(BaseItem item, CancellationToken cancellationToken)
|
||||
private Task SaveItem(BaseItem item, CancellationToken cancellationToken)
|
||||
{
|
||||
return ItemRepository.SaveItem(item, cancellationToken);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user