diff --git a/frontend/src/components/player/AudioPlayer.tsx b/frontend/src/components/player/AudioPlayer.tsx index 1745548..fe445ab 100644 --- a/frontend/src/components/player/AudioPlayer.tsx +++ b/frontend/src/components/player/AudioPlayer.tsx @@ -115,7 +115,7 @@ export default function AudioPlayer() { : `${m}:${sec.toString().padStart(2, '0')}` } - const currentChapter = chapters.findLast?.((c: any) => currentTime >= c.start) || chapters[0] + const currentChapter = [...chapters].reverse().find((c: any) => currentTime >= c.start) || chapters[0] const addBookmark = async () => { if (!item) return diff --git a/frontend/src/components/player/ChapterList.tsx b/frontend/src/components/player/ChapterList.tsx index a270e9a..aef3200 100644 --- a/frontend/src/components/player/ChapterList.tsx +++ b/frontend/src/components/player/ChapterList.tsx @@ -17,7 +17,10 @@ export default function ChapterList({ chapters, currentTime, onSeek }: Props) { : `${m}:${sec.toString().padStart(2, '0')}` } - const active = chapters.findLastIndex?.((c) => currentTime >= c.start) ?? -1 + let active = -1 + for (let i = 0; i < chapters.length; i++) { + if (currentTime >= chapters[i].start) active = i + } return (
diff --git a/frontend/src/pages/Library.tsx b/frontend/src/pages/Library.tsx index 04b6694..92786e0 100644 --- a/frontend/src/pages/Library.tsx +++ b/frontend/src/pages/Library.tsx @@ -50,8 +50,8 @@ export default function Library() { const searchDebounce = useCallback( (() => { - let t: ReturnType - return (v: string) => { clearTimeout(t); setSearch(v); setPage(0) } + let t: ReturnType | undefined + return (v: string) => { clearTimeout(t); t = setTimeout(() => { setSearch(v); setPage(0) }, 300) } })(), [] )