mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-06-06 18:52:43 +02:00
New data model Book media type contains Audiobooks updates
This commit is contained in:
@@ -3,12 +3,12 @@ const Logger = require('../../Logger')
|
||||
class LibraryItemProgress {
|
||||
constructor(progress) {
|
||||
this.id = null // Same as library item id
|
||||
this.libararyItemId = null
|
||||
this.libraryItemId = null
|
||||
|
||||
this.totalDuration = null // seconds
|
||||
this.progress = null // 0 to 1
|
||||
this.currentTime = null // seconds
|
||||
this.isRead = false
|
||||
this.isFinished = false
|
||||
|
||||
this.lastUpdate = null
|
||||
this.startedAt = null
|
||||
@@ -22,11 +22,11 @@ class LibraryItemProgress {
|
||||
toJSON() {
|
||||
return {
|
||||
id: this.id,
|
||||
libararyItemId: this.libararyItemId,
|
||||
libraryItemId: this.libraryItemId,
|
||||
totalDuration: this.totalDuration,
|
||||
progress: this.progress,
|
||||
currentTime: this.currentTime,
|
||||
isRead: this.isRead,
|
||||
isFinished: this.isFinished,
|
||||
lastUpdate: this.lastUpdate,
|
||||
startedAt: this.startedAt,
|
||||
finishedAt: this.finishedAt
|
||||
@@ -35,11 +35,11 @@ class LibraryItemProgress {
|
||||
|
||||
construct(progress) {
|
||||
this.id = progress.id
|
||||
this.libararyItemId = progress.libararyItemId
|
||||
this.libraryItemId = progress.libraryItemId
|
||||
this.totalDuration = progress.totalDuration
|
||||
this.progress = progress.progress
|
||||
this.currentTime = progress.currentTime
|
||||
this.isRead = !!progress.isRead
|
||||
this.isFinished = !!progress.isFinished
|
||||
this.lastUpdate = progress.lastUpdate
|
||||
this.startedAt = progress.startedAt
|
||||
this.finishedAt = progress.finishedAt || null
|
||||
@@ -59,11 +59,11 @@ class LibraryItemProgress {
|
||||
// If has < 10 seconds remaining mark as read
|
||||
var timeRemaining = this.totalDuration - this.currentTime
|
||||
if (timeRemaining < 10) {
|
||||
this.isRead = true
|
||||
this.isFinished = true
|
||||
this.progress = 1
|
||||
this.finishedAt = Date.now()
|
||||
} else {
|
||||
this.isRead = false
|
||||
this.isFinished = false
|
||||
this.finishedAt = null
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ class LibraryItemProgress {
|
||||
var hasUpdates = false
|
||||
for (const key in payload) {
|
||||
if (this[key] !== undefined && payload[key] !== this[key]) {
|
||||
if (key === 'isRead') {
|
||||
if (key === 'isFinished') {
|
||||
if (!payload[key]) { // Updating to Not Read - Reset progress and current time
|
||||
this.finishedAt = null
|
||||
this.progress = 0
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
const Logger = require('../../Logger')
|
||||
const { isObject } = require('../../utils')
|
||||
const AudioBookmark = require('./AudioBookmark')
|
||||
const LibraryItemProgress = require('./LibraryItemProgress')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user