fix: play tracks from the right discs

fixes #275
This commit is contained in:
Lei Nelissen
2025-02-28 11:14:14 +01:00
parent c8e693991b
commit 9229bae007
2 changed files with 10 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
import React, { PropsWithChildren, useCallback } from 'react';
import { Pressable, ViewStyle } from 'react-native';
interface TouchableHandlerProps<T = number> {
interface TouchableHandlerProps<T> {
id: T;
onPress: (id: T) => void;
onLongPress?: (id: T) => void;

View File

@@ -148,12 +148,15 @@ const TrackListView: React.FC<TrackListViewProps> = ({
// Setup callbacks
const playEntity = useCallback(() => { playTracks(trackIds); }, [playTracks, trackIds]);
const shuffleEntity = useCallback(() => { playTracks(trackIds, { shuffle: true }); }, [playTracks, trackIds]);
const selectTrack = useCallback(async (index: number) => {
await playTracks(trackIds, { playIndex: index });
const selectTrack = useCallback(async (trackId: string) => {
const index = trackIds.findIndex((id) => id === trackId);
if (index) {
await playTracks(trackIds, { playIndex: index });
}
}, [playTracks, trackIds]);
const longPressTrack = useCallback((index: number) => {
navigation.navigate('TrackPopupMenu', { trackId: trackIds[index].toString() });
}, [navigation, trackIds]);
const longPressTrack = useCallback((trackId: string) => {
navigation.navigate('TrackPopupMenu', { trackId });
}, [navigation]);
const downloadAllTracks = useCallback(() => {
trackIds.forEach((trackId) => dispatch(queueTrackForDownload(trackId)));
}, [dispatch, trackIds]);
@@ -190,7 +193,7 @@ const TrackListView: React.FC<TrackListViewProps> = ({
{groupTrackIds.map((trackId, i) =>
<TouchableHandler
key={trackId}
id={i}
id={trackId}
onPress={selectTrack}
onLongPress={longPressTrack}
testID={`play-track-${trackId}`}