From fa2db899011346452411ec0403789c264757f74f Mon Sep 17 00:00:00 2001 From: mattsigal Date: Thu, 11 Jun 2026 22:48:50 -0700 Subject: [PATCH] fix(home): resolve missing library images and incorrect sorting in multi-server My Media row - Remove forced alphabetical sorting in getAggregatedLibraries to preserve the server-defined custom ordering. - Add primaryImageAspectRatio to AggregatedLibrary and parse it from Jellyfin/Emby UserViews API. - Update getAggregatedLibraryTiles to forward primaryImageAspectRatio to the home screen item. - Modify the poster aspect ratio check on the home screen to permit library poster images when PrimaryImageAspectRatio is null. --- lib/data/models/aggregated_library.dart | 2 ++ lib/data/repositories/multi_server_repository.dart | 5 +++-- lib/data/repositories/user_views_repository.dart | 1 + lib/ui/screens/home/home_screen.dart | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/data/models/aggregated_library.dart b/lib/data/models/aggregated_library.dart index 152b1ab8..6057eb4d 100644 --- a/lib/data/models/aggregated_library.dart +++ b/lib/data/models/aggregated_library.dart @@ -3,6 +3,7 @@ class AggregatedLibrary { final String name; final String collectionType; final String serverId; + final double? primaryImageAspectRatio; final Map? imageTags; final List? backdropImageTags; @@ -11,6 +12,7 @@ class AggregatedLibrary { required this.name, required this.collectionType, required this.serverId, + this.primaryImageAspectRatio, this.imageTags, this.backdropImageTags, }); diff --git a/lib/data/repositories/multi_server_repository.dart b/lib/data/repositories/multi_server_repository.dart index c32fc707..a424fbb8 100644 --- a/lib/data/repositories/multi_server_repository.dart +++ b/lib/data/repositories/multi_server_repository.dart @@ -166,6 +166,7 @@ class MultiServerRepository { : name, collectionType: data['CollectionType'] as String? ?? '', serverId: session.server.id, + primaryImageAspectRatio: (data['PrimaryImageAspectRatio'] as num?)?.toDouble(), imageTags: data['ImageTags'] != null ? Map.from(data['ImageTags'] as Map) : null, backdropImageTags: (data['BackdropImageTags'] as List?)?.map((e) => e.toString()).toList(), ); @@ -174,8 +175,7 @@ class MultiServerRepository { ), ); - return results.expand((e) => e).toList() - ..sort((a, b) => a.name.compareTo(b.name)); + return results.expand((e) => e).toList(); } Future getAggregatedResume({int limit = _defaultLimit}) async { @@ -694,6 +694,7 @@ class MultiServerRepository { 'Name': lib.name, 'CollectionType': lib.collectionType, 'Type': 'CollectionFolder', + if (lib.primaryImageAspectRatio != null) 'PrimaryImageAspectRatio': lib.primaryImageAspectRatio, if (lib.imageTags != null) 'ImageTags': lib.imageTags, if (lib.backdropImageTags != null) 'BackdropImageTags': lib.backdropImageTags, }, diff --git a/lib/data/repositories/user_views_repository.dart b/lib/data/repositories/user_views_repository.dart index 1237d6c6..8ec2d2c7 100644 --- a/lib/data/repositories/user_views_repository.dart +++ b/lib/data/repositories/user_views_repository.dart @@ -20,6 +20,7 @@ class UserViewsRepository extends ChangeNotifier { name: data['Name'] as String, collectionType: data['CollectionType'] as String? ?? '', serverId: data['ServerId'] as String? ?? '', + primaryImageAspectRatio: (data['PrimaryImageAspectRatio'] as num?)?.toDouble(), imageTags: data['ImageTags'] != null ? Map.from(data['ImageTags'] as Map) : null, backdropImageTags: (data['BackdropImageTags'] as List?)?.map((e) => e.toString()).toList(), ); diff --git a/lib/ui/screens/home/home_screen.dart b/lib/ui/screens/home/home_screen.dart index 386d025c..53a719bf 100644 --- a/lib/ui/screens/home/home_screen.dart +++ b/lib/ui/screens/home/home_screen.dart @@ -3795,7 +3795,7 @@ class _ContentRowsState extends State<_ContentRows> ) { if (imageType == ImageType.poster && isMyMediaRow) { final primaryAr = item.rawData['PrimaryImageAspectRatio'] as num?; - if (primaryAr == null || primaryAr >= 1.0) { + if (primaryAr != null && primaryAr >= 1.0) { return null; } }