From 5eb86b686b61f0fab4214b76aebf1a446e5c9b5f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 7 Nov 2015 20:17:32 -0500 Subject: [PATCH] update notifications --- .../Notifications/Notifications.cs | 49 +++++++++++++------ 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifications.cs b/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifications.cs index 8d21d9a777..a9e4aaa0b6 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifications.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifications.cs @@ -22,6 +22,8 @@ using System.Globalization; using System.Linq; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Controller.Channels; +using MediaBrowser.Controller.LiveTv; namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications { @@ -77,9 +79,9 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications _appHost.HasPendingRestartChanged += _appHost_HasPendingRestartChanged; _appHost.HasUpdateAvailableChanged += _appHost_HasUpdateAvailableChanged; _appHost.ApplicationUpdated += _appHost_ApplicationUpdated; - _deviceManager.CameraImageUploaded +=_deviceManager_CameraImageUploaded; + _deviceManager.CameraImageUploaded += _deviceManager_CameraImageUploaded; - _userManager.UserLockedOut += _userManager_UserLockedOut; + _userManager.UserLockedOut += _userManager_UserLockedOut; } async void _userManager_UserLockedOut(object sender, GenericEventArgs e) @@ -311,25 +313,42 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications private readonly List _itemsAdded = new List(); void _libraryManager_ItemAdded(object sender, ItemChangeEventArgs e) { - if (e.Item.LocationType == LocationType.FileSystem && !e.Item.IsFolder) + if (!FilterItem(e.Item)) { - lock (_libraryChangedSyncLock) + return; + } + + lock (_libraryChangedSyncLock) + { + if (LibraryUpdateTimer == null) { - if (LibraryUpdateTimer == null) - { - LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, 5000, - Timeout.Infinite); - } - else - { - LibraryUpdateTimer.Change(5000, Timeout.Infinite); - } - - _itemsAdded.Add(e.Item); + LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, 5000, + Timeout.Infinite); } + else + { + LibraryUpdateTimer.Change(5000, Timeout.Infinite); + } + + _itemsAdded.Add(e.Item); } } + private bool FilterItem(BaseItem item) + { + if (!item.IsFolder && item.LocationType == LocationType.Virtual) + { + return false; + } + + if (item is IItemByName && !(item is MusicArtist)) + { + return false; + } + + return !(item is IChannelItem) && !(item is ILiveTvItem); + } + private async void LibraryUpdateTimerCallback(object state) { List items;