fix(chapters): sort chapter list entries, localize strings, fix tick keys

This commit is contained in:
Uruk
2026-05-22 12:06:53 +02:00
parent e649414e3f
commit 87b181b66f
5 changed files with 50 additions and 9 deletions

View File

@@ -14,6 +14,23 @@ export interface ChapterMarker {
percent: number;
}
export interface ChapterEntry {
chapter: ChapterInfo;
/** Chapter start, in milliseconds. */
positionMs: number;
}
/** Chapters paired with their millisecond start, sorted ascending by start. */
export const sortedChapters = (
chapters: ChapterInfo[] | null | undefined,
): ChapterEntry[] =>
(chapters ?? [])
.map((chapter) => ({
chapter,
positionMs: (chapter.StartPositionTicks ?? 0) / TICKS_PER_MS,
}))
.sort((a, b) => a.positionMs - b.positionMs);
/** Chapter start positions in milliseconds, ascending. */
export const chapterStartsMs = (
chapters: ChapterInfo[] | null | undefined,