Compare commits

..

No commits in common. "30c327d92abfc8aa6f9c01be3f5f54044aea7b3b" and "293851d9310dca2fb1807ed610aefae1208e491f" have entirely different histories.

View file

@ -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 })
}
}