mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
|
|
||
|
export const state = () => ({
|
||
|
user: null,
|
||
|
streamAudiobook: null,
|
||
|
showEditModal: false,
|
||
|
selectedAudiobook: null,
|
||
|
playOnLoad: false,
|
||
|
isScanning: false,
|
||
|
scanProgress: null
|
||
|
})
|
||
|
|
||
|
export const getters = {
|
||
|
getToken: (state) => {
|
||
|
return state.user ? state.user.token : null
|
||
|
},
|
||
|
getUserAudiobook: (state) => (audiobookId) => {
|
||
|
return state.user && state.user.audiobooks ? state.user.audiobooks[audiobookId] || null : null
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export const actions = {
|
||
|
|
||
|
}
|
||
|
|
||
|
export const mutations = {
|
||
|
setUser(state, user) {
|
||
|
state.user = user
|
||
|
console.log('SETUSER', user)
|
||
|
if (user.token) {
|
||
|
localStorage.setItem('token', user.token)
|
||
|
}
|
||
|
},
|
||
|
setStreamAudiobook(state, audiobook) {
|
||
|
state.playOnLoad = true
|
||
|
state.streamAudiobook = audiobook
|
||
|
},
|
||
|
setStream(state, stream) {
|
||
|
state.playOnLoad = false
|
||
|
state.streamAudiobook = stream ? stream.audiobook : null
|
||
|
},
|
||
|
clearStreamAudiobook(state, audiobookId) {
|
||
|
if (state.streamAudiobook && state.streamAudiobook.id === audiobookId) {
|
||
|
state.playOnLoad = false
|
||
|
state.streamAudiobook = null
|
||
|
}
|
||
|
},
|
||
|
setPlayOnLoad(state, val) {
|
||
|
state.playOnLoad = val
|
||
|
},
|
||
|
showEditModal(state, audiobook) {
|
||
|
state.selectedAudiobook = audiobook
|
||
|
state.showEditModal = true
|
||
|
},
|
||
|
setShowEditModal(state, val) {
|
||
|
state.showEditModal = val
|
||
|
},
|
||
|
setIsScanning(state, isScanning) {
|
||
|
state.isScanning = isScanning
|
||
|
},
|
||
|
setScanProgress(state, progress) {
|
||
|
state.scanProgress = progress
|
||
|
}
|
||
|
}
|