mirror of
https://github.com/austinried/subtracks.git
synced 2025-12-29 09:29:29 +01:00
fixed song list play order mismatch
also sort by disc/track correctly
This commit is contained in:
parent
58cee33af7
commit
06e84fec8d
@ -59,6 +59,7 @@ export interface Song {
|
|||||||
artistId?: string
|
artistId?: string
|
||||||
title: string
|
title: string
|
||||||
track?: number
|
track?: number
|
||||||
|
discNumber?: number
|
||||||
duration?: number
|
duration?: number
|
||||||
starred?: Date
|
starred?: Date
|
||||||
|
|
||||||
|
|||||||
@ -37,9 +37,15 @@ const Songs = React.memo<{
|
|||||||
|
|
||||||
if (type === 'album') {
|
if (type === 'album') {
|
||||||
typeName = 'Album'
|
typeName = 'Album'
|
||||||
_songs
|
if (_songs.some(s => s.track === undefined)) {
|
||||||
.sort((a, b) => a.title.localeCompare(b.title)) //
|
_songs.sort((a, b) => a.title.localeCompare(b.title))
|
||||||
.sort((a, b) => (a.track || 0) - (b.track || 0))
|
} else {
|
||||||
|
_songs.sort((a, b) => {
|
||||||
|
const aVal = (a.track as number) + (a.discNumber !== undefined ? a.discNumber * 10000 : 0)
|
||||||
|
const bVal = (b.track as number) + (b.discNumber !== undefined ? b.discNumber * 10000 : 0)
|
||||||
|
return aVal - bVal
|
||||||
|
})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
typeName = 'Playlist'
|
typeName = 'Playlist'
|
||||||
}
|
}
|
||||||
@ -62,8 +68,8 @@ const Songs = React.memo<{
|
|||||||
contextId={itemId}
|
contextId={itemId}
|
||||||
queueId={i}
|
queueId={i}
|
||||||
subtitle={s.artist}
|
subtitle={s.artist}
|
||||||
onPress={() => setQueue(songs, name, type, itemId, i)}
|
onPress={() => setQueue(_songs, name, type, itemId, i)}
|
||||||
showArt={type === 'playlist'}
|
showArt={false}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</View>
|
</View>
|
||||||
@ -86,9 +92,11 @@ const SongListDetails = React.memo<{
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
{songList.itemType === 'album' && (
|
<HeaderBar
|
||||||
<HeaderBar headerStyle={{ backgroundColor: headerColor }} title={title} contextItem={songList} />
|
headerStyle={{ backgroundColor: headerColor }}
|
||||||
)}
|
title={title}
|
||||||
|
contextItem={songList.itemType === 'album' ? songList : undefined}
|
||||||
|
/>
|
||||||
<ImageGradientScrollView
|
<ImageGradientScrollView
|
||||||
imagePath={coverArtFile?.file?.path}
|
imagePath={coverArtFile?.file?.path}
|
||||||
style={styles.container}
|
style={styles.container}
|
||||||
|
|||||||
@ -46,6 +46,7 @@ export const createMusicMapSlice = (set: SetState<Store>, get: GetState<Store>):
|
|||||||
artistId: child.artistId,
|
artistId: child.artistId,
|
||||||
title: child.title,
|
title: child.title,
|
||||||
track: child.track,
|
track: child.track,
|
||||||
|
discNumber: child.discNumber,
|
||||||
duration: child.duration,
|
duration: child.duration,
|
||||||
starred: child.starred,
|
starred: child.starred,
|
||||||
coverArt: coverArt || (await get().getAlbumCoverArt(child.albumId)),
|
coverArt: coverArt || (await get().getAlbumCoverArt(child.albumId)),
|
||||||
|
|||||||
@ -11,6 +11,8 @@ export type TrackExt = Track & {
|
|||||||
coverArt?: string
|
coverArt?: string
|
||||||
artistId?: string
|
artistId?: string
|
||||||
albumId?: string
|
albumId?: string
|
||||||
|
track?: number
|
||||||
|
discNumber?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Progress = {
|
export type Progress = {
|
||||||
|
|||||||
@ -34,6 +34,8 @@ export const createTrackPlayerMapSlice = (set: SetState<Store>, get: GetState<St
|
|||||||
duration: song.duration,
|
duration: song.duration,
|
||||||
artistId: song.artistId,
|
artistId: song.artistId,
|
||||||
albumId: song.albumId,
|
albumId: song.albumId,
|
||||||
|
track: song.track,
|
||||||
|
discNumber: song.discNumber,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -53,6 +55,8 @@ export const createTrackPlayerMapSlice = (set: SetState<Store>, get: GetState<St
|
|||||||
duration: track.duration,
|
duration: track.duration,
|
||||||
artistId: track.artistId,
|
artistId: track.artistId,
|
||||||
albumId: track.albumId,
|
albumId: track.albumId,
|
||||||
|
track: track.track,
|
||||||
|
discNumber: track.discNumber,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user