Lazy bookshelf finalized

This commit is contained in:
advplyr 2021-12-01 19:07:03 -06:00
parent 5c92aef048
commit 1ef9a689bc
53 changed files with 914 additions and 795 deletions

View file

@ -124,6 +124,14 @@ class Audiobook {
return this._audioFiles.filter(af => af.invalid).map(af => ({ filename: af.filename, error: af.error || 'Unknown Error' }))
}
get numMissingParts() {
return this.missingParts ? this.missingParts.length : 0
}
get numInvalidParts() {
return this.invalidParts ? this.invalidParts.length : 0
}
get _audioFiles() { return this.audioFiles || [] }
get _otherFiles() { return this.otherFiles || [] }
get _tracks() { return this.tracks || [] }
@ -206,8 +214,8 @@ class Audiobook {
chapters: this.chapters || [],
isMissing: !!this.isMissing,
isInvalid: !!this.isInvalid,
hasMissingParts: this.missingParts ? this.missingParts.length : 0,
hasInvalidParts: this.invalidParts ? this.invalidParts.length : 0
hasMissingParts: this.numMissingParts,
hasInvalidParts: this.numInvalidParts
}
}
@ -238,8 +246,8 @@ class Audiobook {
chapters: this.chapters || [],
isMissing: !!this.isMissing,
isInvalid: !!this.isInvalid,
hasMissingParts: this.missingParts ? this.missingParts.length : 0,
hasInvalidParts: this.invalidParts ? this.invalidParts.length : 0
hasMissingParts: this.numMissingParts,
hasInvalidParts: this.numInvalidParts
}
}
@ -419,7 +427,6 @@ class Audiobook {
update(payload) {
var hasUpdates = false
if (payload.tags && payload.tags.join(',') !== this.tags.join(',')) {
this.tags = payload.tags
hasUpdates = true

View file

@ -215,7 +215,7 @@ class User {
}
var wasUpdated = this.audiobooks[audiobook.id].update(updatePayload)
if (wasUpdated) {
Logger.debug(`[User] UserAudiobookData was updated ${JSON.stringify(this.audiobooks[audiobook.id])}`)
// Logger.debug(`[User] UserAudiobookData was updated ${JSON.stringify(this.audiobooks[audiobook.id])}`)
return this.audiobooks[audiobook.id]
}
return false
@ -276,6 +276,7 @@ class User {
}
getAudiobookJSON(audiobookId) {
if (!this.audiobooks) return null
return this.audiobooks[audiobookId] ? this.audiobooks[audiobookId].toJSON() : null
}

View file

@ -85,7 +85,6 @@ class UserAudiobookData {
update(payload) {
var hasUpdates = false
Logger.debug(`[UserAudiobookData] Update called ${JSON.stringify(payload)}`)
for (const key in payload) {
if (payload[key] !== this[key]) {
if (key === 'isRead') {