mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-12 20:31:36 +00:00
Merge 067d3f6394 into 82aec5f60c
This commit is contained in:
commit
9c72fbdcdb
5 changed files with 117 additions and 6 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue