mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-09 10:51:37 +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
|
* @param {import('./User').ProgressUpdatePayload} progressPayload
|
||||||
* @returns {Promise<MediaProgress>}
|
* @returns {Promise<MediaProgress>}
|
||||||
*/
|
*/
|
||||||
async applyProgressUpdate(progressPayload) {
|
applyProgressUpdate(progressPayload) {
|
||||||
if (!this.extraData) this.extraData = {}
|
if (!this.extraData) this.extraData = {}
|
||||||
if (progressPayload.isFinished !== undefined) {
|
if (progressPayload.isFinished !== undefined) {
|
||||||
if (progressPayload.isFinished && !this.isFinished) {
|
if (progressPayload.isFinished && !this.isFinished) {
|
||||||
|
|
@ -243,23 +243,14 @@ class MediaProgress extends Model {
|
||||||
this.finishedAt = null
|
this.finishedAt = null
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.save()
|
|
||||||
|
|
||||||
// For local sync
|
// For local sync
|
||||||
if (progressPayload.lastUpdate) {
|
if (progressPayload.lastUpdate) {
|
||||||
if (isNaN(new Date(progressPayload.lastUpdate))) {
|
this.updatedAt = progressPayload.lastUpdate
|
||||||
Logger.warn(`[MediaProgress] Invalid date provided for lastUpdate: ${progressPayload.lastUpdate} (media item ${this.mediaItemId})`)
|
Logger.info(`[MediaProgress] Manually setting updatedAt to ${this.updatedAt} (media item ${this.mediaItemId})`)
|
||||||
} else {
|
this.changed('updatedAt', true)
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this
|
return this.save({ silent: !!progressPayload.lastUpdate })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue