From 3e423839a11154b951b25cadc03cc96774c2c459 Mon Sep 17 00:00:00 2001 From: Josh Vincent Date: Mon, 4 Aug 2025 18:33:06 -0600 Subject: [PATCH] Fixes UI for Bulk Chapter adder, and changes logic around locking --- client/pages/audiobook/_id/chapters.vue | 56 ++++++++++++++++--------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/client/pages/audiobook/_id/chapters.vue b/client/pages/audiobook/_id/chapters.vue index ffd9df661..7e09935f8 100644 --- a/client/pages/audiobook/_id/chapters.vue +++ b/client/pages/audiobook/_id/chapters.vue @@ -207,8 +207,8 @@

- {{ $strings.LabelDurationFound }} {{ $secondsToTimestamp(chapterData.runtimeLengthSec) }}
+ {{ $strings.LabelDurationFound }} {{ $secondsToTimestamp(chapterData.runtimeLengthSec) }} +
{{ chapterData.chapters.length }} {{ $strings.LabelChaptersFound }}

@@ -244,12 +244,13 @@

{{ $strings.MessageChapterStartIsAfter }}

-
- {{ $strings.ButtonMapChapterTitles }} - - info - -
+
+
+ {{ $strings.ButtonMapChapterTitles }} + + info + +
{{ $strings.ButtonApplyChapters }}
@@ -262,9 +263,8 @@
-
-

{{ $strings.HeaderBulkChapterModal }}

-

{{ $strings.MessageBulkChapterPattern }}

+
+

{{ $strings.MessageBulkChapterPattern }}

{{ $strings.LabelDetectedPattern }} "{{ detectedPattern.before }}{{ formatNumberWithPadding(detectedPattern.startingNumber, detectedPattern) }}{{ detectedPattern.after }}" @@ -272,13 +272,15 @@ {{ $strings.LabelNextChapters }} "{{ detectedPattern.before }}{{ formatNumberWithPadding(detectedPattern.startingNumber + 1, detectedPattern) }}{{ detectedPattern.after }}", "{{ detectedPattern.before }}{{ formatNumberWithPadding(detectedPattern.startingNumber + 2, detectedPattern) }}{{ detectedPattern.after }}", etc.
-
- - +
+ +
+
-
- {{ $strings.ButtonAddChapters }} +
{{ $strings.ButtonCancel }} +
+ {{ $strings.ButtonAddChapters }}
@@ -414,7 +416,7 @@ export default { currentStartTime += track.duration } this.newChapters = chapters - + this.lockedChapters = new Set() this.checkChapters() }, toggleRemoveBranding() { @@ -707,7 +709,7 @@ export default { }, applyChapterNamesOnly() { this.newChapters.forEach((chapter, index) => { - if (this.chapterData.chapters[index]) { + if (this.chapterData.chapters[index] && !this.lockedChapters.has(chapter.id)) { chapter.title = this.chapterData.chapters[index].title } }) @@ -719,7 +721,7 @@ export default { }, applyChapterData() { let index = 0 - this.newChapters = this.chapterData.chapters + const audibleChapters = this.chapterData.chapters .filter((chap) => chap.startOffsetSec < this.mediaDuration) .map((chap) => { return { @@ -729,6 +731,21 @@ export default { title: chap.title } }) + + const merged = [] + let audibleIdx = 0 + for (let i = 0; i < Math.max(this.newChapters.length, audibleChapters.length); i++) { + const isLocked = this.lockedChapters.has(i) + if (isLocked && this.newChapters[i]) { + merged.push({ ...this.newChapters[i], id: i }) + } else if (audibleChapters[audibleIdx]) { + merged.push({ ...audibleChapters[audibleIdx], id: i }) + audibleIdx++ + } else if (this.newChapters[i]) { + merged.push({ ...this.newChapters[i], id: i }) + } + } + this.newChapters = merged this.showFindChaptersModal = false this.chapterData = null @@ -827,6 +844,7 @@ export default { } ] } + this.lockedChapters = new Set() this.checkChapters() }, removeAllChaptersClick() {