add working player
All checks were successful
Deploy App / build (push) Successful in 1m20s
Deploy App / deploy (push) Successful in 16s

This commit is contained in:
valere
2025-10-04 00:49:12 +02:00
parent fef1a8c234
commit 96ffb4b10a
9 changed files with 242 additions and 153 deletions

View File

@@ -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 lindex de la track courante
const index = tracksInCompilation.findIndex(t => t.id === track.id)
// Retourner la track suivante ou null si cest la dernière
return index >= 0 && index < tracksInCompilation.length - 1
? tracksInCompilation[index + 1]
: null
}
}
},
})