fix: TypeScript-Fehler im Frontend beheben

- AudioPlayer: findLast → reverse().find() (ES2022 Kompatibilität)
- ChapterList: findLastIndex → manuelles for-loop + implizit any behoben
- Library: searchDebounce Variable 't' undefined → korrekte Initialisierung

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Audiolib
2026-05-26 13:16:16 +02:00
parent 52c10a7518
commit c65b8ba5cf
3 changed files with 7 additions and 4 deletions

View File

@@ -115,7 +115,7 @@ export default function AudioPlayer() {
: `${m}:${sec.toString().padStart(2, '0')}` : `${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 () => { const addBookmark = async () => {
if (!item) return if (!item) return

View File

@@ -17,7 +17,10 @@ export default function ChapterList({ chapters, currentTime, onSeek }: Props) {
: `${m}:${sec.toString().padStart(2, '0')}` : `${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 ( return (
<div className="mt-4 border-t border-white/10 pt-4 max-h-64 overflow-y-auto"> <div className="mt-4 border-t border-white/10 pt-4 max-h-64 overflow-y-auto">

View File

@@ -50,8 +50,8 @@ export default function Library() {
const searchDebounce = useCallback( const searchDebounce = useCallback(
(() => { (() => {
let t: ReturnType<typeof setTimeout> let t: ReturnType<typeof setTimeout> | undefined
return (v: string) => { clearTimeout(t); setSearch(v); setPage(0) } return (v: string) => { clearTimeout(t); t = setTimeout(() => { setSearch(v); setPage(0) }, 300) }
})(), })(),
[] []
) )