This commit is contained in:
wakamex 2026-07-10 06:51:24 +02:00 committed by GitHub
commit 9c72fbdcdb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 117 additions and 6 deletions

View file

@ -261,6 +261,19 @@ class Book extends Model {
return this.audioFiles.filter((af) => !af.exclude)
}
/**
* Recalculate the book duration from the included (non-excluded) audio files.
* Sets `this.duration` and returns whether it changed.
*
* @returns {boolean}
*/
updateDuration() {
const newDuration = this.includedAudioFiles.reduce((total, af) => total + (isNaN(af.duration) ? 0 : Number(af.duration)), 0)
if (this.duration === newDuration) return false
this.duration = newDuration
return true
}
get hasMediaFiles() {
return !!this.hasAudioTracks || !!this.ebookFile
}