Enhance metadata handling and UI feedback: add support for jingles in channel queries, implement error handling for metadata provider requests, and improve search functionality in ShowMetadataCard with user feedback for no results found. Update translations for new UI messages.
This commit is contained in:
@@ -16,8 +16,10 @@ public sealed class GetChannelQueryHandler(IAppDbContext dbContext)
|
||||
var channel = await dbContext.Channels.AsNoTracking()
|
||||
.Include(c => c.Shows)
|
||||
.Include(c => c.Ads)
|
||||
.Include(c => c.Jingles)
|
||||
.Include(c => c.Overrides)
|
||||
.ThenInclude(o => o.Shows)
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(c => c.Id == query.Id, cancellationToken);
|
||||
if (channel is null)
|
||||
return Result.Failure<ChannelDto>(ChannelErrors.NotFound);
|
||||
|
||||
@@ -52,6 +52,7 @@ public sealed class ScheduleGenerator(
|
||||
.Include(c => c.Jingles)
|
||||
.Include(c => c.Overrides)
|
||||
.ThenInclude(o => o.Shows)
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(c => c.Id == channelId, cancellationToken);
|
||||
|
||||
if (channel is null || !channel.IsEnabled)
|
||||
|
||||
@@ -23,4 +23,9 @@ public static class MetadataErrors
|
||||
"Metadata.NoLinkedSource",
|
||||
"У шоу не привязан внешний источник — сначала найдите шоу в TMDb/OMDb."
|
||||
);
|
||||
|
||||
public static readonly Error ProviderRequestFailed = Error.Validation(
|
||||
"Metadata.ProviderRequestFailed",
|
||||
"Источник метаданных вернул ошибку — проверьте API-ключ."
|
||||
);
|
||||
}
|
||||
|
||||
+12
-2
@@ -19,7 +19,17 @@ public sealed class SearchShowMetadataQueryHandler(IMetadataProviderResolver res
|
||||
if (string.IsNullOrWhiteSpace(query.Query))
|
||||
return Result.Success<IReadOnlyList<MetadataCandidate>>([]);
|
||||
|
||||
var results = await provider.SearchShowsAsync(query.Query, cancellationToken);
|
||||
return Result.Success(results);
|
||||
try
|
||||
{
|
||||
var results = await provider.SearchShowsAsync(query.Query, cancellationToken);
|
||||
return Result.Success(results);
|
||||
}
|
||||
catch (Exception ex) when (ex is HttpRequestException or TaskCanceledException)
|
||||
{
|
||||
// Не-2xx (например, 401 — неверный ключ) или сетевой сбой источника.
|
||||
return Result.Failure<IReadOnlyList<MetadataCandidate>>(
|
||||
MetadataErrors.ProviderRequestFailed
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user