mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-05-25 12:51:31 +00:00
feat: implement smart speed UI and state persistence
This commit is contained in:
parent
4299fdce59
commit
fa2460868e
7 changed files with 150 additions and 2 deletions
|
|
@ -19,7 +19,8 @@ export const state = () => ({
|
|||
authorSortDesc: false,
|
||||
jumpForwardAmount: 10,
|
||||
jumpBackwardAmount: 10,
|
||||
enableSmartSpeed: false
|
||||
enableSmartSpeed: false,
|
||||
smartSpeedRatio: 2.5
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -200,5 +201,17 @@ export const mutations = {
|
|||
if (!settings) return
|
||||
localStorage.setItem('userSettings', JSON.stringify(settings))
|
||||
state.settings = settings
|
||||
},
|
||||
SET_SMART_SPEED_ENABLED(state, enabled) {
|
||||
state.settings.enableSmartSpeed = enabled !== undefined ? enabled : !state.settings.enableSmartSpeed
|
||||
localStorage.setItem('userSettings', JSON.stringify(state.settings))
|
||||
},
|
||||
SET_SMART_SPEED_RATIO(state, ratio) {
|
||||
let clampedRatio = Number(ratio)
|
||||
if (isNaN(clampedRatio)) clampedRatio = 2.5
|
||||
if (clampedRatio < 1.5) clampedRatio = 1.5
|
||||
if (clampedRatio > 5.0) clampedRatio = 5.0
|
||||
state.settings.smartSpeedRatio = clampedRatio
|
||||
localStorage.setItem('userSettings', JSON.stringify(state.settings))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue