2022-04-15 00:15:52 +02:00
|
|
|
const { BookCoverAspectRatio } = require('../../utils/constants')
|
|
|
|
|
|
|
|
class LibrarySettings {
|
|
|
|
constructor(settings) {
|
2022-08-13 20:56:37 +02:00
|
|
|
this.coverAspectRatio = BookCoverAspectRatio.SQUARE
|
2022-04-15 00:15:52 +02:00
|
|
|
this.disableWatcher = false
|
2022-04-27 02:36:29 +02:00
|
|
|
this.skipMatchingMediaWithAsin = false
|
|
|
|
this.skipMatchingMediaWithIsbn = false
|
2022-08-17 01:24:47 +02:00
|
|
|
this.autoScanCronExpression = null
|
2022-04-15 00:15:52 +02:00
|
|
|
|
|
|
|
if (settings) {
|
|
|
|
this.construct(settings)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
construct(settings) {
|
2022-08-13 20:56:37 +02:00
|
|
|
this.coverAspectRatio = !isNaN(settings.coverAspectRatio) ? settings.coverAspectRatio : BookCoverAspectRatio.SQUARE
|
2022-04-15 00:15:52 +02:00
|
|
|
this.disableWatcher = !!settings.disableWatcher
|
2022-04-27 02:36:29 +02:00
|
|
|
this.skipMatchingMediaWithAsin = !!settings.skipMatchingMediaWithAsin
|
|
|
|
this.skipMatchingMediaWithIsbn = !!settings.skipMatchingMediaWithIsbn
|
2022-08-17 01:24:47 +02:00
|
|
|
this.autoScanCronExpression = settings.autoScanCronExpression || null
|
2022-04-15 00:15:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
toJSON() {
|
|
|
|
return {
|
2022-08-13 20:56:37 +02:00
|
|
|
coverAspectRatio: this.coverAspectRatio,
|
2022-04-27 02:36:29 +02:00
|
|
|
disableWatcher: this.disableWatcher,
|
|
|
|
skipMatchingMediaWithAsin: this.skipMatchingMediaWithAsin,
|
2022-08-17 01:24:47 +02:00
|
|
|
skipMatchingMediaWithIsbn: this.skipMatchingMediaWithIsbn,
|
|
|
|
autoScanCronExpression: this.autoScanCronExpression
|
2022-04-15 00:15:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|