diff --git a/client/pages/audiobook/_id/chapters.vue b/client/pages/audiobook/_id/chapters.vue
index f3067e2b..9c191fa6 100644
--- a/client/pages/audiobook/_id/chapters.vue
+++ b/client/pages/audiobook/_id/chapters.vue
@@ -18,11 +18,35 @@
@@ -186,6 +211,8 @@ export default {
return {
newChapters: [],
selectedChapter: null,
+ showShiftTimes: false,
+ shiftAmount: 0,
audioEl: null,
isPlayingChapter: false,
isLoadingChapter: false,
@@ -237,6 +264,32 @@ export default {
}
},
methods: {
+ shiftChapterTimes() {
+ if (!this.shiftAmount || isNaN(this.shiftAmount) || this.newChapters.length <= 1) {
+ return
+ }
+
+ const amount = Number(this.shiftAmount)
+
+ const lastChapter = this.newChapters[this.newChapters.length - 1]
+ if (lastChapter.start + amount > this.mediaDurationRounded) {
+ this.$toast.error('Invalid shift amount. Last chapter start time would extend beyond the duration of this audiobook.')
+ return
+ }
+
+ if (this.newChapters[0].end + amount <= 0) {
+ this.$toast.error('Invalid shift amount. First chapter would have zero or negative length.')
+ return
+ }
+
+ for (let i = 0; i < this.newChapters.length; i++) {
+ const chap = this.newChapters[i]
+ chap.end = Math.min(chap.end + amount, this.mediaDuration)
+ if (i > 0) {
+ chap.start = Math.max(0, chap.start + amount)
+ }
+ }
+ },
editItem() {
this.$store.commit('showEditModal', this.libraryItem)
},