diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d521025..bf256866 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix synchronizing trakt lists from users with special characters in their username - Note that these lists MUST be added as URLs; the short-form `user/list` will NOT work with special characters - Fix local subtitle scanner to detect non-lowercase extensions (e.g. `Movie (2000).EN.SRT`) +- Fix adding a single image to a manual collection from search results +- Fix loading manual collection view when collection contains images ### Changed - Remove some unnecessary API calls related to media server scanning and paging diff --git a/ErsatzTV.Application/MediaCards/Queries/GetCollectionCardsHandler.cs b/ErsatzTV.Application/MediaCards/Queries/GetCollectionCardsHandler.cs index e913b858..7c579dee 100644 --- a/ErsatzTV.Application/MediaCards/Queries/GetCollectionCardsHandler.cs +++ b/ErsatzTV.Application/MediaCards/Queries/GetCollectionCardsHandler.cs @@ -97,6 +97,12 @@ public class GetCollectionCardsHandler : .Include(c => c.MediaItems) .ThenInclude(i => (i as Song).MediaVersions) .ThenInclude(mv => mv.MediaFiles) + .Include(c => c.MediaItems) + .ThenInclude(i => (i as Image).ImageMetadata) + .ThenInclude(ovm => ovm.Artwork) + .Include(c => c.MediaItems) + .ThenInclude(i => (i as Image).MediaVersions) + .ThenInclude(mv => mv.MediaFiles) .SelectOneAsync(c => c.Id, c => c.Id == request.Id) .Map(c => c.ToEither(BaseError.New("Unable to load collection"))) .MapT(c => ProjectToViewModel(c, maybeJellyfin, maybeEmby)); diff --git a/ErsatzTV/Pages/Search.razor b/ErsatzTV/Pages/Search.razor index 10e26e7a..10a12e80 100644 --- a/ErsatzTV/Pages/Search.razor +++ b/ErsatzTV/Pages/Search.razor @@ -654,6 +654,27 @@ Right: _ => Snackbar.Add($"Added {song.Title} to collection {collection.Name}", Severity.Success)); } } + + if (card is ImageCardViewModel image) + { + var parameters = new DialogParameters { { "EntityType", "image" }, { "EntityName", image.Title } }; + var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall }; + + IDialogReference dialog = await Dialog.ShowAsync("Add To Collection", parameters, options); + DialogResult result = await dialog.Result; + if (result is { Canceled: false, Data: MediaCollectionViewModel collection }) + { + var request = new AddImageToCollection(collection.Id, image.ImageId); + Either addResult = await Mediator.Send(request, CancellationToken); + addResult.Match( + Left: error => + { + Snackbar.Add($"Unexpected error adding image to collection: {error.Value}"); + Logger.LogError("Unexpected error adding image to collection: {Error}", error.Value); + }, + Right: _ => Snackbar.Add($"Added {image.Title} to collection {collection.Name}", Severity.Success)); + } + } } private string GetMoviesLink()