From d6e55e29132ac0c46106d82f69c030a449139733 Mon Sep 17 00:00:00 2001 From: ta264 Date: Tue, 9 Nov 2021 21:35:20 +0000 Subject: [PATCH] Fixed: Deleted books removed from UI --- src/NzbDrone.Core/AuthorStats/AuthorStatisticsService.cs | 7 ++++++- src/Readarr.Api.V1/Books/BookController.cs | 1 + src/Readarr.Api.V1/Books/BookResource.cs | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core/AuthorStats/AuthorStatisticsService.cs b/src/NzbDrone.Core/AuthorStats/AuthorStatisticsService.cs index e1df59fcd..f86566c6e 100644 --- a/src/NzbDrone.Core/AuthorStats/AuthorStatisticsService.cs +++ b/src/NzbDrone.Core/AuthorStats/AuthorStatisticsService.cs @@ -114,7 +114,12 @@ public void Handle(BookEditedEvent message) public void Handle(BookFileDeletedEvent message) { _cache.Remove("AllAuthors"); - _cache.Remove(message.BookFile.Author.Value.Id.ToString()); + + var authorId = message.BookFile.Author?.Value?.Id.ToString(); + if (authorId != null) + { + _cache.Remove(authorId); + } } } } diff --git a/src/Readarr.Api.V1/Books/BookController.cs b/src/Readarr.Api.V1/Books/BookController.cs index 213d99532..f8e708f60 100644 --- a/src/Readarr.Api.V1/Books/BookController.cs +++ b/src/Readarr.Api.V1/Books/BookController.cs @@ -28,6 +28,7 @@ public class BookController : BookControllerWithSignalR, IHandle, IHandle, IHandle, + IHandle, IHandle, IHandle, IHandle diff --git a/src/Readarr.Api.V1/Books/BookResource.cs b/src/Readarr.Api.V1/Books/BookResource.cs index 12c3267b9..ca5129bbc 100644 --- a/src/Readarr.Api.V1/Books/BookResource.cs +++ b/src/Readarr.Api.V1/Books/BookResource.cs @@ -52,7 +52,7 @@ public static BookResource ToResource(this Book model) var selectedEdition = model.Editions?.Value.Where(x => x.Monitored).SingleOrDefault(); var title = selectedEdition?.Title ?? model.Title; - var authorTitle = $"{model.Author.Value.Metadata.Value.SortNameLastFirst} {title}"; + var authorTitle = $"{model.Author?.Value?.Metadata?.Value?.SortNameLastFirst} {title}"; return new BookResource {