Refactored the way cover images are updated from SignalR to use an explicit event that is sent at a granular level for a given type of entity. (#1046)

Fixed a bad event listener for RefreshMetadata (now removed) to update metadata on Series Detail. Now uses ScanService, which indicates a series has completed a scan.
This commit is contained in:
Joseph Milazzo 2022-02-07 17:44:06 -08:00 committed by GitHub
parent c448a3e493
commit 67ba5e302f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 108 additions and 117 deletions

View file

@ -6,8 +6,10 @@ using API.Data;
using API.DTOs.CollectionTags;
using API.Entities.Metadata;
using API.Extensions;
using API.SignalR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
namespace API.Controllers
{
@ -17,11 +19,13 @@ namespace API.Controllers
public class CollectionController : BaseApiController
{
private readonly IUnitOfWork _unitOfWork;
private readonly IHubContext<MessageHub> _messageHub;
/// <inheritdoc />
public CollectionController(IUnitOfWork unitOfWork)
public CollectionController(IUnitOfWork unitOfWork, IHubContext<MessageHub> messageHub)
{
_unitOfWork = unitOfWork;
_messageHub = messageHub;
}
/// <summary>
@ -152,6 +156,7 @@ namespace API.Controllers
{
tag.CoverImageLocked = false;
tag.CoverImage = string.Empty;
await _messageHub.Clients.All.SendAsync(SignalREvents.CoverUpdate, MessageFactory.CoverUpdateEvent(tag.Id, "collection"));
_unitOfWork.CollectionTagRepository.Update(tag);
}