Review SHOULD-FIX (#145): the SPA graphics picker could go stale because Blazor ran RefreshGraphicsElements (disk->DB sync) before listing, while the API endpoint never refreshed — a newly added .yml would not appear. GET /api/graphics-elements?refresh=true now sends RefreshGraphicsElements before the list query; default false leaves existing callers untouched. The playback troubleshooting screen passes refresh=true. Controller tests cover refresh-iff-true ordering; regenerated OpenAPI v1.json (endpoint index and generated TS schemas unchanged - query params are not part of either). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
32 lines
1.2 KiB
C#
32 lines
1.2 KiB
C#
using ErsatzTV.Application.Graphics;
|
|
using ErsatzTV.Core.Api.Graphics;
|
|
using MediatR;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace ErsatzTV.Controllers.Api;
|
|
|
|
[ApiController]
|
|
public class GraphicsElementController(IMediator mediator) : ControllerBase
|
|
{
|
|
[HttpGet("/api/graphics-elements", Name = "GetGraphicsElements")]
|
|
[Tags("Graphics Elements")]
|
|
[EndpointSummary("Get all graphics elements")]
|
|
[EndpointDescription(
|
|
"Returns all graphics elements. Pass refresh=true to first re-sync the on-disk graphics element " +
|
|
"definitions into the database (matching the legacy Blazor behavior) so newly added files appear.")]
|
|
[EndpointGroupName("general")]
|
|
[ProducesResponseType(typeof(List<GraphicsElementResponseModel>), StatusCodes.Status200OK)]
|
|
public async Task<List<GraphicsElementResponseModel>> GetAll(
|
|
[FromQuery] bool refresh,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
if (refresh)
|
|
{
|
|
await mediator.Send(new RefreshGraphicsElements(), cancellationToken);
|
|
}
|
|
|
|
return await mediator.Send(new GetAllGraphicsElementsForApi(), cancellationToken);
|
|
}
|
|
}
|