1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 10:32:35 +01:00

Fixed signalR for Missing/Wanted

This commit is contained in:
Mark McDowall 2014-06-28 09:45:50 -07:00
parent 5dcc6a74eb
commit 293e6cac6d
5 changed files with 16 additions and 41 deletions

View File

@ -3,7 +3,6 @@
using System.Linq;
using NzbDrone.Api.Episodes;
using NzbDrone.Api.Extensions;
using NzbDrone.Api.Mapping;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Tv;
@ -17,7 +16,7 @@ public class CalendarModule : EpisodeModuleWithSignalR<EpisodeResource, Episode>
public CalendarModule(ICommandExecutor commandExecutor,
IEpisodeService episodeService,
SeriesRepository seriesRepository)
: base(commandExecutor, "calendar")
: base(episodeService, commandExecutor, "calendar")
{
_episodeService = episodeService;
_seriesRepository = seriesRepository;
@ -26,11 +25,6 @@ public CalendarModule(ICommandExecutor commandExecutor,
GetResourceById = GetEpisode;
}
private EpisodeResource GetEpisode(int id)
{
return _episodeService.GetEpisode(id).InjectTo<EpisodeResource>();
}
private List<EpisodeResource> GetCalendar()
{
var start = DateTime.Today;

View File

@ -1,9 +1,5 @@
using System.Collections.Generic;
using NzbDrone.Api.Mapping;
using NzbDrone.Api.REST;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.Download;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Tv;
@ -15,7 +11,7 @@ public class EpisodeModule : EpisodeModuleWithSignalR<EpisodeResource, Episode>
private readonly IEpisodeService _episodeService;
public EpisodeModule(ICommandExecutor commandExecutor, IEpisodeService episodeService)
: base(commandExecutor)
: base(episodeService, commandExecutor)
{
_episodeService = episodeService;
@ -40,29 +36,5 @@ private void SetMonitored(EpisodeResource episodeResource)
{
_episodeService.SetEpisodeMonitored(episodeResource.Id, episodeResource.Monitored);
}
private EpisodeResource GetEpisode(int id)
{
return _episodeService.GetEpisode(id).InjectTo<EpisodeResource>();
}
public void Handle(EpisodeGrabbedEvent message)
{
foreach (var episode in message.Episode.Episodes)
{
var resource = episode.InjectTo<EpisodeResource>();
resource.Grabbed = true;
BroadcastResourceChange(ModelAction.Updated, resource);
}
}
public void Handle(EpisodeDownloadedEvent message)
{
foreach (var episode in message.Episode.Episodes)
{
BroadcastResourceChange(ModelAction.Updated, episode.Id);
}
}
}
}

View File

@ -14,14 +14,23 @@ public abstract class EpisodeModuleWithSignalR<TResource, TModel> : NzbDroneRest
where TResource : EpisodeResource, new()
where TModel : Episode
{
protected EpisodeModuleWithSignalR(ICommandExecutor commandExecutor)
private readonly IEpisodeService _episodeService;
protected EpisodeModuleWithSignalR(IEpisodeService episodeService, ICommandExecutor commandExecutor)
: base(commandExecutor)
{
_episodeService = episodeService;
}
protected EpisodeModuleWithSignalR(ICommandExecutor commandExecutor, string resource)
protected EpisodeModuleWithSignalR(IEpisodeService episodeService, ICommandExecutor commandExecutor, string resource)
: base(commandExecutor, resource)
{
_episodeService = episodeService;
}
protected EpisodeResource GetEpisode(int id)
{
return _episodeService.GetEpisode(id).InjectTo<EpisodeResource>();
}
public void Handle(EpisodeGrabbedEvent message)

View File

@ -12,8 +12,8 @@ public class CutoffModule : EpisodeModuleWithSignalR<EpisodeResource, Episode>
private readonly IEpisodeCutoffService _episodeCutoffService;
private readonly ISeriesRepository _seriesRepository;
public CutoffModule(IEpisodeCutoffService episodeCutoffService, ISeriesRepository seriesRepository, ICommandExecutor commandExecutor)
:base(commandExecutor, "wanted/cutoff")
public CutoffModule(IEpisodeService episodeService, IEpisodeCutoffService episodeCutoffService, ISeriesRepository seriesRepository, ICommandExecutor commandExecutor)
:base(episodeService, commandExecutor, "wanted/cutoff")
{
_episodeCutoffService = episodeCutoffService;
_seriesRepository = seriesRepository;

View File

@ -13,7 +13,7 @@ public class MissingModule : EpisodeModuleWithSignalR<EpisodeResource, Episode>
private readonly ISeriesRepository _seriesRepository;
public MissingModule(IEpisodeService episodeService, ISeriesRepository seriesRepository, ICommandExecutor commandExecutor)
:base(commandExecutor, "wanted/missing")
:base(episodeService, commandExecutor, "wanted/missing")
{
_episodeService = episodeService;
_seriesRepository = seriesRepository;