2021-08-18 00:01:11 +02:00
|
|
|
|
|
|
|
export const state = () => ({
|
|
|
|
user: null,
|
|
|
|
streamAudiobook: null,
|
|
|
|
showEditModal: false,
|
|
|
|
selectedAudiobook: null,
|
|
|
|
playOnLoad: false,
|
|
|
|
isScanning: false,
|
2021-08-23 21:08:54 +02:00
|
|
|
scanProgress: null,
|
|
|
|
developerMode: false
|
2021-08-18 00:01:11 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
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
|
|
|
|
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) {
|
2021-08-19 01:31:19 +02:00
|
|
|
if (progress > 0) state.isScanning = true
|
2021-08-18 00:01:11 +02:00
|
|
|
state.scanProgress = progress
|
2021-08-23 21:08:54 +02:00
|
|
|
},
|
|
|
|
setDeveloperMode(state, val) {
|
|
|
|
state.developerMode = val
|
2021-08-18 00:01:11 +02:00
|
|
|
}
|
|
|
|
}
|