mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-02 01:05:25 +02:00
Merge branch 'advplyr:master' into master
This commit is contained in:
commit
cd5e5099f2
23 changed files with 586 additions and 319 deletions
|
@ -1,4 +1,5 @@
|
|||
const Folder = require('./Folder')
|
||||
const LibrarySettings = require('./settings/LibrarySettings')
|
||||
const { getId } = require('../utils/index')
|
||||
|
||||
class Library {
|
||||
|
@ -10,9 +11,9 @@ class Library {
|
|||
this.icon = 'database' // database, podcast, book, audiobook, comic
|
||||
this.mediaType = 'book' // book, podcast
|
||||
this.provider = 'google'
|
||||
this.disableWatcher = false
|
||||
|
||||
this.lastScan = 0
|
||||
this.settings = null
|
||||
|
||||
this.createdAt = null
|
||||
this.lastUpdate = null
|
||||
|
@ -25,6 +26,9 @@ class Library {
|
|||
get folderPaths() {
|
||||
return this.folders.map(f => f.fullPath)
|
||||
}
|
||||
get isPodcast() {
|
||||
return this.mediaType === 'podcast'
|
||||
}
|
||||
|
||||
construct(library) {
|
||||
this.id = library.id
|
||||
|
@ -34,7 +38,11 @@ class Library {
|
|||
this.icon = library.icon || 'database'
|
||||
this.mediaType = library.mediaType
|
||||
this.provider = library.provider || 'google'
|
||||
this.disableWatcher = !!library.disableWatcher
|
||||
|
||||
this.settings = new LibrarySettings(library.settings)
|
||||
if (library.settings === undefined) { // LibrarySettings added in v2, migrate settings
|
||||
this.settings.disableWatcher = !!library.disableWatcher
|
||||
}
|
||||
|
||||
this.createdAt = library.createdAt
|
||||
this.lastUpdate = library.lastUpdate
|
||||
|
@ -62,7 +70,7 @@ class Library {
|
|||
icon: this.icon,
|
||||
mediaType: this.mediaType,
|
||||
provider: this.provider,
|
||||
disableWatcher: this.disableWatcher,
|
||||
settings: this.settings.toJSON(),
|
||||
createdAt: this.createdAt,
|
||||
lastUpdate: this.lastUpdate
|
||||
}
|
||||
|
@ -89,7 +97,7 @@ class Library {
|
|||
this.icon = data.icon || 'database'
|
||||
this.mediaType = data.mediaType || 'book'
|
||||
this.provider = data.provider || 'google'
|
||||
this.disableWatcher = !!data.disableWatcher
|
||||
this.settings = new LibrarySettings(data.settings)
|
||||
this.createdAt = Date.now()
|
||||
this.lastUpdate = Date.now()
|
||||
}
|
||||
|
@ -105,10 +113,10 @@ class Library {
|
|||
}
|
||||
})
|
||||
|
||||
if (payload.disableWatcher !== this.disableWatcher) {
|
||||
this.disableWatcher = !!payload.disableWatcher
|
||||
if (payload.settings && this.settings.update(payload.settings)) {
|
||||
hasUpdates = true
|
||||
}
|
||||
|
||||
if (!isNaN(payload.displayOrder) && payload.displayOrder !== this.displayOrder) {
|
||||
this.displayOrder = Number(payload.displayOrder)
|
||||
hasUpdates = true
|
||||
|
|
34
server/objects/settings/LibrarySettings.js
Normal file
34
server/objects/settings/LibrarySettings.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
const { BookCoverAspectRatio } = require('../../utils/constants')
|
||||
const Logger = require('../../Logger')
|
||||
|
||||
class LibrarySettings {
|
||||
constructor(settings) {
|
||||
this.disableWatcher = false
|
||||
|
||||
if (settings) {
|
||||
this.construct(settings)
|
||||
}
|
||||
}
|
||||
|
||||
construct(settings) {
|
||||
this.disableWatcher = !!settings.disableWatcher
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
disableWatcher: this.disableWatcher
|
||||
}
|
||||
}
|
||||
|
||||
update(payload) {
|
||||
var hasUpdates = false
|
||||
for (const key in payload) {
|
||||
if (this[key] !== payload[key]) {
|
||||
this[key] = payload[key]
|
||||
hasUpdates = true
|
||||
}
|
||||
}
|
||||
return hasUpdates
|
||||
}
|
||||
}
|
||||
module.exports = LibrarySettings
|
|
@ -1,5 +1,5 @@
|
|||
const { BookCoverAspectRatio, BookshelfView } = require('../utils/constants')
|
||||
const Logger = require('../Logger')
|
||||
const { BookCoverAspectRatio, BookshelfView } = require('../../utils/constants')
|
||||
const Logger = require('../../Logger')
|
||||
|
||||
class ServerSettings {
|
||||
constructor(settings) {
|
Loading…
Add table
Add a link
Reference in a new issue