favorite: v0.1
All checks were successful
Deploy App / build (push) Successful in 1m9s
Deploy App / deploy (push) Successful in 15s

This commit is contained in:
valere
2025-10-16 02:04:12 +02:00
parent 0aa1a57b78
commit 61b0b6395f
4 changed files with 98 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
import type { Box, Artist, Track } from '~/../types/types'
import { FAVORITES_BOX_ID, useFavoritesStore } from '~/store/favorites'
// stores/data.ts
import { defineStore } from 'pinia'
@@ -44,6 +45,21 @@ export const useDataStore = defineStore('data', {
artist: artistObj
}
})
const favBox: Box = {
id: FAVORITES_BOX_ID,
type: 'playlist',
name: 'Favoris',
duration: 0,
tracks: [],
description: '',
color1: '#0f172a',
color2: '#1e293b',
color3: '#334155',
state: 'box-list'
}
if (!this.boxes.find((b) => b.id === FAVORITES_BOX_ID)) {
this.boxes = [favBox, ...this.boxes]
}
this.isLoaded = true
const uiStore = useUiStore()
uiStore.closeBox()
@@ -59,6 +75,12 @@ export const useDataStore = defineStore('data', {
},
// Obtenir toutes les pistes d'une box donnée
getTracksByboxId: (state) => (id: string) => {
if (id === FAVORITES_BOX_ID) {
const fav = useFavoritesStore()
return fav.trackIds
.map((tid) => state.tracks.find((t) => t.id === tid))
.filter((t): t is Track => !!t)
}
return state.tracks.filter((track) => track.boxId === id)
},
// Filtrer les artistes selon certains critères