From c65b8ba5cf4762b75794453bfda9eb0d480909c8 Mon Sep 17 00:00:00 2001 From: Audiolib Date: Tue, 26 May 2026 13:16:16 +0200 Subject: [PATCH] fix: TypeScript-Fehler im Frontend beheben MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- frontend/src/components/player/AudioPlayer.tsx | 2 +- frontend/src/components/player/ChapterList.tsx | 5 ++++- frontend/src/pages/Library.tsx | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) 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) } })(), [] )