mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-01-01 04:00:45 -05:00
Compare commits
2 Commits
v2.19.2
...
fix-chapte
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4d99a118f | ||
|
|
5ca12eee19 |
@@ -85,7 +85,8 @@ export default {
|
||||
displayTitle: null,
|
||||
currentPlaybackRate: 1,
|
||||
syncFailedToast: null,
|
||||
coverAspectRatio: 1
|
||||
coverAspectRatio: 1,
|
||||
lastChapterId: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -236,12 +237,16 @@ export default {
|
||||
}
|
||||
}, 1000)
|
||||
},
|
||||
checkChapterEnd(time) {
|
||||
checkChapterEnd() {
|
||||
if (!this.currentChapter) return
|
||||
const chapterEndTime = this.currentChapter.end
|
||||
const tolerance = 0.75
|
||||
if (time >= chapterEndTime - tolerance) {
|
||||
this.sleepTimerEnd()
|
||||
|
||||
// Track chapter transitions by comparing current chapter with last chapter
|
||||
if (this.lastChapterId !== this.currentChapter.id) {
|
||||
// Chapter changed - if we had a previous chapter, this means we crossed a boundary
|
||||
if (this.lastChapterId) {
|
||||
this.sleepTimerEnd()
|
||||
}
|
||||
this.lastChapterId = this.currentChapter.id
|
||||
}
|
||||
},
|
||||
sleepTimerEnd() {
|
||||
@@ -301,7 +306,7 @@ export default {
|
||||
}
|
||||
|
||||
if (this.sleepTimerType === this.$constants.SleepTimerTypes.CHAPTER && this.sleepTimerSet) {
|
||||
this.checkChapterEnd(time)
|
||||
this.checkChapterEnd()
|
||||
}
|
||||
},
|
||||
setDuration(duration) {
|
||||
|
||||
@@ -5,7 +5,7 @@ const authorFilters = require('./authorFilters')
|
||||
|
||||
const ShareManager = require('../../managers/ShareManager')
|
||||
const { profile } = require('../profiler')
|
||||
|
||||
const stringifySequelizeQuery = require('../stringifySequelizeQuery')
|
||||
const countCache = new Map()
|
||||
|
||||
module.exports = {
|
||||
@@ -345,7 +345,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
async findAndCountAll(findOptions, limit, offset) {
|
||||
const findOptionsKey = JSON.stringify(findOptions)
|
||||
const findOptionsKey = stringifySequelizeQuery(findOptions)
|
||||
Logger.debug(`[LibraryItemsBookFilters] findOptionsKey: ${findOptionsKey}`)
|
||||
|
||||
findOptions.limit = limit || null
|
||||
@@ -353,6 +353,7 @@ module.exports = {
|
||||
|
||||
if (countCache.has(findOptionsKey)) {
|
||||
const rows = await Database.bookModel.findAll(findOptions)
|
||||
|
||||
return { rows, count: countCache.get(findOptionsKey) }
|
||||
} else {
|
||||
const result = await Database.bookModel.findAndCountAll(findOptions)
|
||||
|
||||
34
server/utils/stringifySequelizeQuery.js
Normal file
34
server/utils/stringifySequelizeQuery.js
Normal file
@@ -0,0 +1,34 @@
|
||||
function stringifySequelizeQuery(findOptions) {
|
||||
// Helper function to handle symbols in nested objects
|
||||
function handleSymbols(obj) {
|
||||
if (!obj || typeof obj !== 'object') return obj
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map(handleSymbols)
|
||||
}
|
||||
|
||||
const newObj = {}
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
// Handle Symbol keys from Object.getOwnPropertySymbols
|
||||
Object.getOwnPropertySymbols(obj).forEach((sym) => {
|
||||
newObj[`__Op.${sym.toString()}`] = handleSymbols(obj[sym])
|
||||
})
|
||||
|
||||
// Handle regular keys
|
||||
if (typeof key === 'string') {
|
||||
if (value && typeof value === 'object' && Object.getPrototypeOf(value) === Symbol.prototype) {
|
||||
// Handle Symbol values
|
||||
newObj[key] = `__Op.${value.toString()}`
|
||||
} else {
|
||||
// Recursively handle nested objects
|
||||
newObj[key] = handleSymbols(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
return newObj
|
||||
}
|
||||
|
||||
const sanitizedOptions = handleSymbols(findOptions)
|
||||
return JSON.stringify(sanitizedOptions)
|
||||
}
|
||||
module.exports = stringifySequelizeQuery
|
||||
Reference in New Issue
Block a user