add working player
This commit is contained in:
@@ -54,5 +54,20 @@ export const useDataStore = defineStore('data', {
|
||||
getTracksByArtistId: (state) => (artistId: number) => {
|
||||
return state.tracks.filter(track => track.artist.id === artistId)
|
||||
},
|
||||
getNextTrack: (state) => {
|
||||
return (track: Track) => {
|
||||
// Récupérer toutes les tracks de la même compilation et les trier par ordre
|
||||
const tracksInCompilation = state.tracks
|
||||
.filter(t => t.compilationId === track.compilationId)
|
||||
.sort((a, b) => a.order - b.order)
|
||||
|
||||
// Trouver l’index de la track courante
|
||||
const index = tracksInCompilation.findIndex(t => t.id === track.id)
|
||||
// Retourner la track suivante ou null si c’est la dernière
|
||||
return index >= 0 && index < tracksInCompilation.length - 1
|
||||
? tracksInCompilation[index + 1]
|
||||
: null
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user