fix: Small improvement to library screen

This commit is contained in:
PartyDonut 2025-10-28 21:44:36 +01:00
parent b2657f6408
commit 16bf5e8a32
3 changed files with 204 additions and 136 deletions

View file

@ -90,23 +90,32 @@ class LibraryScreen extends _$LibraryScreen {
return null;
}
Future<void> loadResume(ViewModel viewModel) async {}
Future<void> loadRecommendations(ViewModel viewModel) async {
List<RecommendedModel> newRecommendations = [];
final latest = await api.usersUserIdItemsLatestGet(
final resume = await api.usersUserIdItemsResumeGet(
parentId: viewModel.id,
limit: 14,
isPlayed: false,
imageTypeLimit: 1,
includeItemTypes: viewModel.collectionType.itemKinds.map((e) => e.dtoKind).toList(),
enableUserData: true,
enableImageTypes: [
ImageType.primary,
ImageType.banner,
ImageType.screenshot,
],
mediaTypes: [MediaType.video],
enableTotalRecordCount: false,
);
newRecommendations = [
...newRecommendations,
RecommendedModel(
name: const Latest(),
posters: latest.body?.map((e) => ItemBaseModel.fromBaseDto(e, ref)).toList() ?? [],
name: const Resume(),
posters: resume.body?.items?.map((e) => ItemBaseModel.fromBaseDto(e, ref)).toList() ?? [],
type: null,
),
];
if (viewModel.collectionType == CollectionType.movies) {
final response = await api.moviesRecommendationsGet(
parentId: viewModel.id,
@ -146,6 +155,22 @@ class LibraryScreen extends _$LibraryScreen {
];
}
final latest = await api.usersUserIdItemsLatestGet(
parentId: viewModel.id,
limit: 14,
isPlayed: false,
imageTypeLimit: 1,
includeItemTypes: viewModel.collectionType.itemKinds.map((e) => e.dtoKind).toList(),
);
newRecommendations = [
...newRecommendations,
RecommendedModel(
name: const Latest(),
posters: latest.body?.map((e) => ItemBaseModel.fromBaseDto(e, ref)).toList() ?? [],
type: null,
),
];
state = state.copyWith(
recommendations: newRecommendations,
);