initiation librodrome

This commit is contained in:
Yvv
2026-02-20 12:55:10 +01:00
commit 35e2897a73
208 changed files with 18951 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
export function useGuidedMode() {
const route = useRoute()
const store = usePlayerStore()
const bookData = useBookData()
const { loadAndPlay } = useAudioPlayer()
async function activateGuidedMode(chapterSlug: string) {
await bookData.init()
if (!store.isGuidedMode) return
const primarySong = bookData.getPrimarySong(chapterSlug)
if (primarySong && primarySong.id !== store.currentSong?.id) {
// Set the chapter's songs as the playlist
const chapterSongs = bookData.getChapterSongs(chapterSlug)
if (chapterSongs.length > 0) {
store.setPlaylist(chapterSongs)
}
loadAndPlay(primarySong)
}
}
// Watch route changes for guided mode
watch(
() => route.params.slug,
async (slug) => {
if (slug && typeof slug === 'string' && store.isGuidedMode) {
await activateGuidedMode(slug)
}
},
)
return {
activateGuidedMode,
}
}