From 8e9a85557e4c0c73d2044b481d6970a4bf175953 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 18 Apr 2021 00:15:22 -0400 Subject: [PATCH] Fixed: No Artist images when adding single Album --- .../Music/Events/ArtistsImportedEvent.cs | 6 +++--- .../Music/Handlers/ArtistAddedHandler.cs | 20 +++++++++++++++++-- .../Music/Services/ArtistService.cs | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Core/Music/Events/ArtistsImportedEvent.cs b/src/NzbDrone.Core/Music/Events/ArtistsImportedEvent.cs index cf1b7786e..428aeda6c 100644 --- a/src/NzbDrone.Core/Music/Events/ArtistsImportedEvent.cs +++ b/src/NzbDrone.Core/Music/Events/ArtistsImportedEvent.cs @@ -5,12 +5,12 @@ namespace NzbDrone.Core.Music.Events { public class ArtistsImportedEvent : IEvent { - public List ArtistIds { get; private set; } + public List Artists { get; private set; } public bool DoRefresh { get; private set; } - public ArtistsImportedEvent(List artistIds, bool doRefresh = true) + public ArtistsImportedEvent(List artists, bool doRefresh = true) { - ArtistIds = artistIds; + Artists = artists; DoRefresh = doRefresh; } } diff --git a/src/NzbDrone.Core/Music/Handlers/ArtistAddedHandler.cs b/src/NzbDrone.Core/Music/Handlers/ArtistAddedHandler.cs index a72a39a63..82397793c 100644 --- a/src/NzbDrone.Core/Music/Handlers/ArtistAddedHandler.cs +++ b/src/NzbDrone.Core/Music/Handlers/ArtistAddedHandler.cs @@ -1,3 +1,4 @@ +using System.Linq; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Music.Commands; @@ -9,10 +10,12 @@ namespace NzbDrone.Core.Music IHandle { private readonly IManageCommandQueue _commandQueueManager; + private readonly IEventAggregator _eventAggregator; - public ArtistAddedHandler(IManageCommandQueue commandQueueManager) + public ArtistAddedHandler(IManageCommandQueue commandQueueManager, IEventAggregator eventAggregator) { _commandQueueManager = commandQueueManager; + _eventAggregator = eventAggregator; } public void Handle(ArtistAddedEvent message) @@ -21,13 +24,26 @@ namespace NzbDrone.Core.Music { _commandQueueManager.Push(new RefreshArtistCommand(message.Artist.Id, true)); } + else + { + // Trigger Artist Metadata download when adding Albums + _eventAggregator.PublishEvent(new ArtistRefreshCompleteEvent(message.Artist)); + } } public void Handle(ArtistsImportedEvent message) { if (message.DoRefresh) { - _commandQueueManager.Push(new BulkRefreshArtistCommand(message.ArtistIds, true)); + _commandQueueManager.Push(new BulkRefreshArtistCommand(message.Artists.Select(a => a.Id).ToList(), true)); + } + else + { + // Trigger Artist Metadata download when adding Albums + foreach (var artist in message.Artists) + { + _eventAggregator.PublishEvent(new ArtistRefreshCompleteEvent(artist)); + } } } } diff --git a/src/NzbDrone.Core/Music/Services/ArtistService.cs b/src/NzbDrone.Core/Music/Services/ArtistService.cs index bd49aeac1..2a39254b5 100644 --- a/src/NzbDrone.Core/Music/Services/ArtistService.cs +++ b/src/NzbDrone.Core/Music/Services/ArtistService.cs @@ -66,7 +66,7 @@ namespace NzbDrone.Core.Music { _cache.Clear(); _artistRepository.InsertMany(newArtists); - _eventAggregator.PublishEvent(new ArtistsImportedEvent(newArtists.Select(s => s.Id).ToList(), doRefresh)); + _eventAggregator.PublishEvent(new ArtistsImportedEvent(newArtists.ToList(), doRefresh)); return newArtists; }