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

View File

@ -1,9 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Api.Mapping;
using NzbDrone.Api.REST; 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.Messaging.Commands;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
@ -15,7 +11,7 @@ namespace NzbDrone.Api.Episodes
private readonly IEpisodeService _episodeService; private readonly IEpisodeService _episodeService;
public EpisodeModule(ICommandExecutor commandExecutor, IEpisodeService episodeService) public EpisodeModule(ICommandExecutor commandExecutor, IEpisodeService episodeService)
: base(commandExecutor) : base(episodeService, commandExecutor)
{ {
_episodeService = episodeService; _episodeService = episodeService;
@ -40,29 +36,5 @@ namespace NzbDrone.Api.Episodes
{ {
_episodeService.SetEpisodeMonitored(episodeResource.Id, episodeResource.Monitored); _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 @@ namespace NzbDrone.Api.Episodes
where TResource : EpisodeResource, new() where TResource : EpisodeResource, new()
where TModel : Episode where TModel : Episode
{ {
protected EpisodeModuleWithSignalR(ICommandExecutor commandExecutor) private readonly IEpisodeService _episodeService;
protected EpisodeModuleWithSignalR(IEpisodeService episodeService, ICommandExecutor commandExecutor)
: base(commandExecutor) : base(commandExecutor)
{ {
_episodeService = episodeService;
} }
protected EpisodeModuleWithSignalR(ICommandExecutor commandExecutor, string resource) protected EpisodeModuleWithSignalR(IEpisodeService episodeService, ICommandExecutor commandExecutor, string resource)
: base(commandExecutor, resource) : base(commandExecutor, resource)
{ {
_episodeService = episodeService;
}
protected EpisodeResource GetEpisode(int id)
{
return _episodeService.GetEpisode(id).InjectTo<EpisodeResource>();
} }
public void Handle(EpisodeGrabbedEvent message) public void Handle(EpisodeGrabbedEvent message)

View File

@ -12,8 +12,8 @@ namespace NzbDrone.Api.Wanted
private readonly IEpisodeCutoffService _episodeCutoffService; private readonly IEpisodeCutoffService _episodeCutoffService;
private readonly ISeriesRepository _seriesRepository; private readonly ISeriesRepository _seriesRepository;
public CutoffModule(IEpisodeCutoffService episodeCutoffService, ISeriesRepository seriesRepository, ICommandExecutor commandExecutor) public CutoffModule(IEpisodeService episodeService, IEpisodeCutoffService episodeCutoffService, ISeriesRepository seriesRepository, ICommandExecutor commandExecutor)
:base(commandExecutor, "wanted/cutoff") :base(episodeService, commandExecutor, "wanted/cutoff")
{ {
_episodeCutoffService = episodeCutoffService; _episodeCutoffService = episodeCutoffService;
_seriesRepository = seriesRepository; _seriesRepository = seriesRepository;

View File

@ -13,7 +13,7 @@ namespace NzbDrone.Api.Wanted
private readonly ISeriesRepository _seriesRepository; private readonly ISeriesRepository _seriesRepository;
public MissingModule(IEpisodeService episodeService, ISeriesRepository seriesRepository, ICommandExecutor commandExecutor) public MissingModule(IEpisodeService episodeService, ISeriesRepository seriesRepository, ICommandExecutor commandExecutor)
:base(commandExecutor, "wanted/missing") :base(episodeService, commandExecutor, "wanted/missing")
{ {
_episodeService = episodeService; _episodeService = episodeService;
_seriesRepository = seriesRepository; _seriesRepository = seriesRepository;