2 Commits
Author SHA1 Message Date
cedric 9f9b408f1f perf: streamer la liste des morceaux sans bloquer le rendu de la page
Déploiement FRONT BETA / check (push) Successful in 2m2s
Déploiement FRONT PROD / check (push) Successful in 2m5s
Déploiement FRONT BETA / deploy (push) Successful in 22s
Déploiement FRONT PROD / deploy (push) Successful in 19s
2026-07-04 00:03:22 +04:00
cedric 15367f388e perf: ne plus précharger le fichier audio entier avant lecture 2026-07-04 00:03:18 +04:00
3 changed files with 24 additions and 19 deletions
+3 -17
View File
@@ -1,7 +1,5 @@
import {Suspense} from 'react' import {Suspense} from 'react'
import {notFound} from 'next/navigation' import TeksDrawerLoader from '../../components/teks/teks-drawer-loader'
import {jwennTeks} from '../../lib/oki-api'
import TeksDrawer from '../../components/teks/teks-drawer'
import {CurrentTrackProvider} from '../../components/teks/current-track-context' import {CurrentTrackProvider} from '../../components/teks/current-track-context'
import Loading from './loading' import Loading from './loading'
@@ -40,23 +38,11 @@ export const metadata = {
} }
} }
async function jwennDotDone() { export default function PawolLayout({children}) {
const teks = await jwennTeks()
if (!teks) {
notFound()
}
return teks
}
export default async function PawolLayout({children}) {
const teks = await jwennDotDone()
return ( return (
<CurrentTrackProvider> <CurrentTrackProvider>
<Suspense fallback={<Loading />}> <Suspense fallback={<Loading />}>
<TeksDrawer paroles={teks} /> <TeksDrawerLoader />
</Suspense> </Suspense>
<section> <section>
{children} {children}
+8 -2
View File
@@ -20,6 +20,12 @@ import {getAlias} from '../../lib/utils/format'
const IMAGE_URL = process.env.NEXT_PUBLIC_API_URL_ROOT || 'http://localhost:1337' const IMAGE_URL = process.env.NEXT_PUBLIC_API_URL_ROOT || 'http://localhost:1337'
function createAudio(src) {
const audio = new Audio(src)
audio.preload = 'metadata'
return audio
}
function parseLrc(text) { function parseLrc(text) {
const lines = [] const lines = []
for (const raw of text.split('\n')) { for (const raw of text.split('\n')) {
@@ -68,7 +74,7 @@ const TinyText = styled(Typography)({
}) })
export default function Lekte({audio, url, parole}) { export default function Lekte({audio, url, parole}) {
const audioRef = useRef(new Audio(audio)) const audioRef = useRef(createAudio(audio))
const intervalRef = useRef() const intervalRef = useRef()
const isReady = useRef(false) const isReady = useRef(false)
const [duration, setDuration] = useState(0) const [duration, setDuration] = useState(0)
@@ -135,7 +141,7 @@ export default function Lekte({audio, url, parole}) {
useEffect(() => { useEffect(() => {
audioRef.current.pause() audioRef.current.pause()
audioRef.current = new Audio(audio) audioRef.current = createAudio(audio)
setIsPlaying(false) setIsPlaying(false)
setVolume(100) setVolume(100)
setPosition(0) setPosition(0)
+13
View File
@@ -0,0 +1,13 @@
import {notFound} from 'next/navigation'
import {jwennTeks} from '../../lib/oki-api'
import TeksDrawer from './teks-drawer'
export default async function TeksDrawerLoader() {
const teks = await jwennTeks()
if (!teks) {
notFound()
}
return <TeksDrawer paroles={teks} />
}