From 32f2d417d3dc4b1b383db6052fd7dff6542efca3 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Wed, 26 May 2021 21:28:13 +0200 Subject: [PATCH] Added EpisodesChanged to signalR series event to notify that episode monitored flag may have changed --- src/NzbDrone.Core/Tv/Events/SeriesEditedEvent.cs | 4 +++- src/NzbDrone.Core/Tv/SeriesService.cs | 5 ++++- src/Sonarr.Api.V3/Series/SeriesModule.cs | 4 +++- src/Sonarr.Api.V3/Series/SeriesResource.cs | 2 ++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core/Tv/Events/SeriesEditedEvent.cs b/src/NzbDrone.Core/Tv/Events/SeriesEditedEvent.cs index a37a6c902..790cd9c16 100644 --- a/src/NzbDrone.Core/Tv/Events/SeriesEditedEvent.cs +++ b/src/NzbDrone.Core/Tv/Events/SeriesEditedEvent.cs @@ -6,11 +6,13 @@ namespace NzbDrone.Core.Tv.Events { public Series Series { get; private set; } public Series OldSeries { get; private set; } + public bool EpisodesChanged { get; private set; } - public SeriesEditedEvent(Series series, Series oldSeries) + public SeriesEditedEvent(Series series, Series oldSeries, bool episodesChanged = false) { Series = series; OldSeries = oldSeries; + EpisodesChanged = episodesChanged; } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/Tv/SeriesService.cs b/src/NzbDrone.Core/Tv/SeriesService.cs index 0699e9d91..e62dc97ea 100644 --- a/src/NzbDrone.Core/Tv/SeriesService.cs +++ b/src/NzbDrone.Core/Tv/SeriesService.cs @@ -175,6 +175,8 @@ namespace NzbDrone.Core.Tv { var storedSeries = GetSeries(series.Id); + var episodeMonitoredChanged = false; + if (updateEpisodesToMatchSeason) { foreach (var season in series.Seasons) @@ -184,6 +186,7 @@ namespace NzbDrone.Core.Tv if (storedSeason != null && season.Monitored != storedSeason.Monitored) { _episodeService.SetEpisodeMonitoredBySeason(series.Id, season.SeasonNumber, season.Monitored); + episodeMonitoredChanged = true; } } } @@ -194,7 +197,7 @@ namespace NzbDrone.Core.Tv var updatedSeries = _seriesRepository.Update(series); if (publishUpdatedEvent) { - _eventAggregator.PublishEvent(new SeriesEditedEvent(updatedSeries, storedSeries)); + _eventAggregator.PublishEvent(new SeriesEditedEvent(updatedSeries, storedSeries, episodeMonitoredChanged)); } return updatedSeries; diff --git a/src/Sonarr.Api.V3/Series/SeriesModule.cs b/src/Sonarr.Api.V3/Series/SeriesModule.cs index 5cdc485ec..1e0fea38b 100644 --- a/src/Sonarr.Api.V3/Series/SeriesModule.cs +++ b/src/Sonarr.Api.V3/Series/SeriesModule.cs @@ -267,7 +267,9 @@ namespace Sonarr.Api.V3.Series public void Handle(SeriesEditedEvent message) { - BroadcastResourceChange(ModelAction.Updated, message.Series.Id); + var resource = GetResourceByIdForBroadcast(message.Series.Id); + resource.EpisodesChanged = message.EpisodesChanged; + BroadcastResourceChange(ModelAction.Updated, resource); } public void Handle(SeriesDeletedEvent message) diff --git a/src/Sonarr.Api.V3/Series/SeriesResource.cs b/src/Sonarr.Api.V3/Series/SeriesResource.cs index 84d7fc76f..d1a93271c 100644 --- a/src/Sonarr.Api.V3/Series/SeriesResource.cs +++ b/src/Sonarr.Api.V3/Series/SeriesResource.cs @@ -64,6 +64,8 @@ namespace Sonarr.Api.V3.Series public Ratings Ratings { get; set; } public SeriesStatisticsResource Statistics { get; set; } + + public bool? EpisodesChanged { get; set; } } public static class SeriesResourceMapper