mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-06 01:11:35 +00:00
Compare commits
No commits in common. "30c327d92abfc8aa6f9c01be3f5f54044aea7b3b" and "293851d9310dca2fb1807ed610aefae1208e491f" have entirely different histories.
30c327d92a
...
293851d931
1 changed files with 5 additions and 14 deletions
|
|
@ -183,7 +183,7 @@ class MediaProgress extends Model {
|
|||
* @param {import('./User').ProgressUpdatePayload} progressPayload
|
||||
* @returns {Promise<MediaProgress>}
|
||||
*/
|
||||
async applyProgressUpdate(progressPayload) {
|
||||
applyProgressUpdate(progressPayload) {
|
||||
if (!this.extraData) this.extraData = {}
|
||||
if (progressPayload.isFinished !== undefined) {
|
||||
if (progressPayload.isFinished && !this.isFinished) {
|
||||
|
|
@ -243,23 +243,14 @@ class MediaProgress extends Model {
|
|||
this.finishedAt = null
|
||||
}
|
||||
|
||||
await this.save()
|
||||
|
||||
// For local sync
|
||||
if (progressPayload.lastUpdate) {
|
||||
if (isNaN(new Date(progressPayload.lastUpdate))) {
|
||||
Logger.warn(`[MediaProgress] Invalid date provided for lastUpdate: ${progressPayload.lastUpdate} (media item ${this.mediaItemId})`)
|
||||
} else {
|
||||
const escapedDate = this.sequelize.escape(new Date(progressPayload.lastUpdate))
|
||||
Logger.info(`[MediaProgress] Manually setting updatedAt to ${escapedDate} (media item ${this.mediaItemId})`)
|
||||
|
||||
await this.sequelize.query(`UPDATE "mediaProgresses" SET "updatedAt" = ${escapedDate} WHERE "id" = '${this.id}'`)
|
||||
|
||||
await this.reload()
|
||||
}
|
||||
this.updatedAt = progressPayload.lastUpdate
|
||||
Logger.info(`[MediaProgress] Manually setting updatedAt to ${this.updatedAt} (media item ${this.mediaItemId})`)
|
||||
this.changed('updatedAt', true)
|
||||
}
|
||||
|
||||
return this
|
||||
return this.save({ silent: !!progressPayload.lastUpdate })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue