mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-20 01:42:35 +01:00
Fixed: Refresh tags after updating autotags
This commit is contained in:
parent
f3ce0ac620
commit
e688dfadf7
@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Cache;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
|
||||
@ -22,14 +23,18 @@ public class AutoTaggingService : IAutoTaggingService
|
||||
{
|
||||
private readonly IAutoTaggingRepository _repository;
|
||||
private readonly RootFolderService _rootFolderService;
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
private readonly ICached<Dictionary<int, AutoTag>> _cache;
|
||||
|
||||
public AutoTaggingService(IAutoTaggingRepository repository,
|
||||
RootFolderService rootFolderService,
|
||||
IEventAggregator eventAggregator,
|
||||
ICacheManager cacheManager)
|
||||
{
|
||||
_repository = repository;
|
||||
_rootFolderService = rootFolderService;
|
||||
_eventAggregator = eventAggregator;
|
||||
|
||||
_cache = cacheManager.GetCache<Dictionary<int, AutoTag>>(typeof(AutoTag), "autoTags");
|
||||
}
|
||||
|
||||
@ -51,13 +56,17 @@ public AutoTag GetById(int id)
|
||||
public void Update(AutoTag autoTag)
|
||||
{
|
||||
_repository.Update(autoTag);
|
||||
|
||||
_cache.Clear();
|
||||
_eventAggregator.PublishEvent(new AutoTagsUpdatedEvent());
|
||||
}
|
||||
|
||||
public AutoTag Insert(AutoTag autoTag)
|
||||
{
|
||||
var result = _repository.Insert(autoTag);
|
||||
|
||||
_cache.Clear();
|
||||
_eventAggregator.PublishEvent(new AutoTagsUpdatedEvent());
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -65,7 +74,9 @@ public AutoTag Insert(AutoTag autoTag)
|
||||
public void Delete(int id)
|
||||
{
|
||||
_repository.Delete(id);
|
||||
|
||||
_cache.Clear();
|
||||
_eventAggregator.PublishEvent(new AutoTagsUpdatedEvent());
|
||||
}
|
||||
|
||||
public List<AutoTag> AllForTag(int tagId)
|
||||
|
8
src/NzbDrone.Core/AutoTagging/AutoTagsUpdatedEvent.cs
Normal file
8
src/NzbDrone.Core/AutoTagging/AutoTagsUpdatedEvent.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using NzbDrone.Common.Messaging;
|
||||
|
||||
namespace NzbDrone.Core.AutoTagging
|
||||
{
|
||||
public class AutoTagsUpdatedEvent : IEvent
|
||||
{
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NzbDrone.Core.AutoTagging;
|
||||
using NzbDrone.Core.Datastore.Events;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Tags;
|
||||
@ -11,7 +12,9 @@
|
||||
namespace Radarr.Api.V3.Tags
|
||||
{
|
||||
[V3ApiController]
|
||||
public class TagController : RestControllerWithSignalR<TagResource, Tag>, IHandle<TagsUpdatedEvent>
|
||||
public class TagController : RestControllerWithSignalR<TagResource, Tag>,
|
||||
IHandle<TagsUpdatedEvent>,
|
||||
IHandle<AutoTagsUpdatedEvent>
|
||||
{
|
||||
private readonly ITagService _tagService;
|
||||
|
||||
@ -59,5 +62,11 @@ public void Handle(TagsUpdatedEvent message)
|
||||
{
|
||||
BroadcastResourceChange(ModelAction.Sync);
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
public void Handle(AutoTagsUpdatedEvent message)
|
||||
{
|
||||
BroadcastResourceChange(ModelAction.Sync);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user