fix: Shuffle play videos (#345)

Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
PartyDonut 2025-05-17 16:35:39 +02:00 committed by GitHub
parent aad081abae
commit 1a8765fbd6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -574,8 +574,11 @@ class LibrarySearchNotifier extends StateNotifier<LibrarySearchModel> {
state = state.copyWith(fetchingItems: false); state = state.copyWith(fetchingItems: false);
//Only try to load video items
itemsToPlay = itemsToPlay.where((element) => FladderItemType.playable.contains(element.type)).toList();
if (itemsToPlay.isNotEmpty) { if (itemsToPlay.isNotEmpty) {
await itemsToPlay.playLibraryItems(context, ref); await itemsToPlay.playLibraryItems(context, ref, shuffle: shuffle);
} else { } else {
fladderSnackbar(context, title: context.localized.libraryFetchNoItemsFound); fladderSnackbar(context, title: context.localized.libraryFetchNoItemsFound);
} }
@ -648,11 +651,12 @@ class LibrarySearchNotifier extends StateNotifier<LibrarySearchModel> {
if (allItems.isNotEmpty) { if (allItems.isNotEmpty) {
if (state.fetchingItems == true) { if (state.fetchingItems == true) {
state = state.copyWith(fetchingItems: false); state = state.copyWith(fetchingItems: false);
final newItemList = shuffle ? allItems.shuffled() : allItems;
await Navigator.of(context, rootNavigator: true).push( await Navigator.of(context, rootNavigator: true).push(
PageTransition( PageTransition(
child: PhotoViewerScreen( child: PhotoViewerScreen(
items: allItems, items: newItemList,
indexOfSelected: selected != null ? allItems.indexOf(selected) : 0, indexOfSelected: selected != null ? newItemList.indexOf(selected) : 0,
), ),
type: PageTransitionType.fade), type: PageTransitionType.fade),
); );