mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-28 13:58:23 +02:00
Add localLIbraryProgress updates
This commit is contained in:
parent
a63022a669
commit
1fed00ca81
1 changed files with 45 additions and 14 deletions
|
@ -354,21 +354,52 @@ export default {
|
||||||
this.$set(this.libraryItem, 'localLibraryItem', item)
|
this.$set(this.libraryItem, 'localLibraryItem', item)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
toggleFinished() {
|
async toggleFinished() {
|
||||||
var updatePayload = {
|
|
||||||
isFinished: !this.userIsFinished
|
|
||||||
}
|
|
||||||
this.isProcessingReadUpdate = true
|
this.isProcessingReadUpdate = true
|
||||||
this.$axios
|
if (this.isLocal || this.localEpisode) {
|
||||||
.$patch(`/api/me/progress/${this.libraryItemId}`, updatePayload)
|
var isFinished = !this.userIsFinished
|
||||||
.then(() => {
|
var localMediaProgressId = this.localLibraryItemId
|
||||||
this.isProcessingReadUpdate = false
|
console.log('toggleFinished local media progress id', localMediaProgressId, isFinished)
|
||||||
})
|
var payload = await this.$db.updateLocalMediaProgressFinished({ localMediaProgressId, isFinished })
|
||||||
.catch((error) => {
|
console.log('toggleFinished payload', JSON.stringify(payload))
|
||||||
console.error('Failed', error)
|
if (!payload || payload.error) {
|
||||||
this.isProcessingReadUpdate = false
|
var errorMsg = payload ? payload.error : 'Unknown error'
|
||||||
})
|
this.$toast.error(errorMsg)
|
||||||
},
|
} else {
|
||||||
|
var localMediaProgress = payload.localMediaProgress
|
||||||
|
console.log('toggleFinished localMediaProgress', JSON.stringify(localMediaProgress))
|
||||||
|
if (localMediaProgress) {
|
||||||
|
this.$store.commit('globals/updateLocalMediaProgress', localMediaProgress)
|
||||||
|
}
|
||||||
|
|
||||||
|
var lmp = this.$store.getters['globals/getLocalMediaProgressById'](this.libraryItemId)
|
||||||
|
console.log('toggleFinished Check LMP', this.libraryItemId, JSON.stringify(lmp))
|
||||||
|
|
||||||
|
var serverUpdated = payload.server
|
||||||
|
if (serverUpdated) {
|
||||||
|
this.$toast.success(`Local & Server Item marked as ${isFinished ? 'Finished' : 'Not Finished'}`)
|
||||||
|
} else {
|
||||||
|
this.$toast.success(`Local Item marked as ${isFinished ? 'Finished' : 'Not Finished'}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.isProcessingReadUpdate = false
|
||||||
|
} else {
|
||||||
|
var updatePayload = {
|
||||||
|
isFinished: !this.userIsFinished
|
||||||
|
}
|
||||||
|
this.$axios
|
||||||
|
.$patch(`/api/me/progress/${this.libraryItemId}`, updatePayload)
|
||||||
|
.then(() => {
|
||||||
|
this.isProcessingReadUpdate = false
|
||||||
|
this.$toast.success(`Item marked as ${updatePayload.isFinished ? 'Finished' : 'Not Finished'}`)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Failed', error)
|
||||||
|
this.isProcessingReadUpdate = false
|
||||||
|
this.$toast.error(`Failed to mark as ${updatePayload.isFinished ? 'Finished' : 'Not Finished'}`)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$eventBus.$on('new-local-library-item', this.newLocalLibraryItem)
|
this.$eventBus.$on('new-local-library-item', this.newLocalLibraryItem)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue