mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-25 16:18:54 +01:00
Update user progress reset and delete logic
This commit is contained in:
parent
11f4caffa8
commit
6cb253598b
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "audiobookshelf-client",
|
||||
"version": "1.1.5",
|
||||
"version": "1.1.6",
|
||||
"description": "Audiobook manager and player",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "audiobookshelf",
|
||||
"version": "1.1.5",
|
||||
"version": "1.1.6",
|
||||
"description": "Self-hosted audiobook server for managing and playing audiobooks.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -109,7 +109,7 @@ class ApiController {
|
||||
// Remove audiobook from users
|
||||
for (let i = 0; i < this.db.users.length; i++) {
|
||||
var user = this.db.users[i]
|
||||
var madeUpdates = user.resetAudiobookProgress(audiobook.id)
|
||||
var madeUpdates = user.deleteAudiobookProgress(audiobook.id)
|
||||
if (madeUpdates) {
|
||||
await this.db.updateEntity('user', user)
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ class Server {
|
||||
Logger.error('[Server] audiobookProgressUpdate invalid socket client')
|
||||
return
|
||||
}
|
||||
client.user.updateAudiobookProgressFromStream(progressPayload)
|
||||
client.user.updateAudiobookProgress(progressPayload.audiobookId, progressPayload)
|
||||
}
|
||||
|
||||
async authenticateSocket(socket, token) {
|
||||
|
@ -205,16 +205,20 @@ class Stream extends EventEmitter {
|
||||
}
|
||||
|
||||
startLoop() {
|
||||
// Logger.info(`[Stream] ${this.audiobookTitle} (${this.id}) Start Loop`)
|
||||
this.socket.emit('stream_progress', { stream: this.id, chunks: [], numSegments: 0, percent: '0%' })
|
||||
this.loop = setInterval(() => {
|
||||
|
||||
clearInterval(this.loop)
|
||||
var intervalId = setInterval(() => {
|
||||
if (!this.isTranscodeComplete) {
|
||||
this.checkFiles()
|
||||
} else {
|
||||
Logger.info(`[Stream] ${this.audiobookTitle} sending stream_ready`)
|
||||
this.socket.emit('stream_ready')
|
||||
clearInterval(this.loop)
|
||||
clearInterval(intervalId)
|
||||
}
|
||||
}, 2000)
|
||||
this.loop = intervalId
|
||||
}
|
||||
|
||||
async start() {
|
||||
@ -260,13 +264,16 @@ class Stream extends EventEmitter {
|
||||
|
||||
this.ffmpeg.on('start', (command) => {
|
||||
Logger.info('[INFO] FFMPEG transcoding started with command: ' + command)
|
||||
Logger.info('')
|
||||
if (this.isResetting) {
|
||||
setTimeout(() => {
|
||||
Logger.info('[STREAM] Clearing isResetting')
|
||||
this.isResetting = false
|
||||
this.startLoop()
|
||||
}, 500)
|
||||
} else {
|
||||
this.startLoop()
|
||||
}
|
||||
this.startLoop()
|
||||
})
|
||||
|
||||
this.ffmpeg.on('stderr', (stdErrline) => {
|
||||
|
@ -184,6 +184,20 @@ class User {
|
||||
}
|
||||
|
||||
resetAudiobookProgress(audiobookId) {
|
||||
if (!this.audiobooks || !this.audiobooks[audiobookId]) {
|
||||
return false
|
||||
}
|
||||
return this.updateAudiobookProgress(audiobookId, {
|
||||
progress: 0,
|
||||
currentTime: 0,
|
||||
isRead: false,
|
||||
lastUpdate: Date.now(),
|
||||
startedAt: null,
|
||||
finishedAt: null
|
||||
})
|
||||
}
|
||||
|
||||
deleteAudiobookProgress(audiobookId) {
|
||||
if (!this.audiobooks || !this.audiobooks[audiobookId]) {
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user