v1.1.20+50
All checks were successful
Flutter Schmutter / build (push) Successful in 3m39s

This commit is contained in:
2025-06-11 18:56:55 +02:00
parent a4d50289c2
commit e38d2086b3
8 changed files with 373 additions and 280 deletions

View File

@ -115,6 +115,17 @@ class MediaNotifier extends StateNotifier<MediaState> {
}
}
List<MediaItem> mergeMediaItems(
List<MediaItem> current,
List<MediaItem> incoming,
) {
final existingIds = current.map((item) => item.id).toSet();
final newItems = incoming
.where((item) => !existingIds.contains(item.id))
.toList();
return [...current, ...newItems];
}
Future<void> loadMedia({int? id}) async {
if (state.isLoading) return;
state = state.replace(isLoading: true);
@ -128,8 +139,11 @@ class MediaNotifier extends StateNotifier<MediaState> {
random: state.random,
tag: state.tag,
);
if (newMedia.isNotEmpty) {
addMediaItems(newMedia);
state = state.replace(
mediaItems: mergeMediaItems(state.mediaItems, newMedia),
);
}
} catch (e) {
print('Fehler beim Laden der Medien: $e');