Hero-admin: voortgangsindicator voor foto's die worden verwerkt, mislukt-melding met opnieuw proberen
Spinner per foto zonder varianten, totaal met voortgangsbalk (aria-valuenow/max), uitleg dat de hero al is opgeslagen, bij 3 mislukte pogingen een melding met 'Opnieuw proberen' (POST /hero/images/{id}/retry; foutstatus staat in het geheugen van de renderer). Test dat een refetch van 5 s onopgeslagen wijzigingen niet overschrijft.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -40,6 +40,13 @@ public interface IHeroImageService
|
||||
/// </summary>
|
||||
void ApplyFocus(HeroImage image, HeroFocusRequest request);
|
||||
|
||||
/// <summary>True when the background renderer gave up on the image after a few failed tries (until a retry or a restart).</summary>
|
||||
bool IsRenderFailed(Guid imageId);
|
||||
|
||||
/// <summary>Lets the background renderer try an image it gave up on again.</summary>
|
||||
/// <exception cref="HeroImageNotFoundException">There is no such image.</exception>
|
||||
Task RetryRenderAsync(Guid imageId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>Wakes the background renderer: there is an image whose set is missing or does not match its focus.</summary>
|
||||
void NotifyPending();
|
||||
|
||||
@@ -77,6 +84,9 @@ public class HeroImageService(
|
||||
var existing = await repository.GetImageBySha256Async(sha, cancellationToken);
|
||||
if (existing is not null && await FilesExistAsync(existing, cancellationToken))
|
||||
{
|
||||
// The same photo again also gives up the failed state: the renderer tries it again when it is still pending.
|
||||
signal?.Reset(existing.Id);
|
||||
signal?.Notify();
|
||||
return HeroMapping.ToImageDto(existing);
|
||||
}
|
||||
|
||||
@@ -148,6 +158,15 @@ public class HeroImageService(
|
||||
|
||||
public void NotifyPending() => signal?.Notify();
|
||||
|
||||
public bool IsRenderFailed(Guid imageId) => signal?.IsGivenUp(imageId) ?? false;
|
||||
|
||||
public async Task RetryRenderAsync(Guid imageId, CancellationToken cancellationToken)
|
||||
{
|
||||
_ = await repository.GetImageAsync(imageId, cancellationToken) ?? throw new HeroImageNotFoundException();
|
||||
signal?.Reset(imageId);
|
||||
signal?.Notify();
|
||||
}
|
||||
|
||||
public async Task<Guid?> RenderNextPendingAsync(IReadOnlySet<Guid> skip, CancellationToken cancellationToken)
|
||||
{
|
||||
var image = (await repository.GetImagesNeedingRenderAsync(cancellationToken)).FirstOrDefault(i => !skip.Contains(i.Id));
|
||||
|
||||
Reference in New Issue
Block a user