mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-26 10:49:00 +02:00
Add: Experimental collections edit, book list, collection cover #151
This commit is contained in:
parent
28ccd4e568
commit
465e6869c0
31 changed files with 555 additions and 60 deletions
|
@ -40,7 +40,7 @@ class UserCollection {
|
|||
var json = this.toJSON()
|
||||
json.books = json.books.map(bookId => {
|
||||
var _ab = audiobooks.find(ab => ab.id === bookId)
|
||||
return _ab ? _ab.toJSON() : null
|
||||
return _ab ? _ab.toJSONExpanded() : null
|
||||
}).filter(b => !!b)
|
||||
return json
|
||||
}
|
||||
|
@ -84,5 +84,24 @@ class UserCollection {
|
|||
this.books = this.books.filter(bid => bid !== bookId)
|
||||
this.lastUpdate = Date.now()
|
||||
}
|
||||
|
||||
update(payload) {
|
||||
let hasUpdates = false
|
||||
for (const key in payload) {
|
||||
if (key === 'books') {
|
||||
if (payload.books && this.books.join(',') !== payload.books.join(',')) {
|
||||
this.books = [...payload.books]
|
||||
hasUpdates = true
|
||||
}
|
||||
} else if (this[key] !== undefined && this[key] !== payload[key]) {
|
||||
hasUpdates = true
|
||||
this[key] = payload[key]
|
||||
}
|
||||
}
|
||||
if (hasUpdates) {
|
||||
this.lastUpdate = Date.now()
|
||||
}
|
||||
return hasUpdates
|
||||
}
|
||||
}
|
||||
module.exports = UserCollection
|
Loading…
Add table
Add a link
Reference in a new issue