2021-09-12 18:37:08 -05:00
|
|
|
import Vue from 'vue'
|
2021-09-01 20:07:11 -05:00
|
|
|
|
|
|
|
export const state = () => ({
|
|
|
|
streamAudiobook: null,
|
2021-09-12 18:37:08 -05:00
|
|
|
playingDownload: null,
|
2021-09-01 20:07:11 -05:00
|
|
|
playOnLoad: false,
|
|
|
|
serverUrl: null,
|
2021-09-12 18:37:08 -05:00
|
|
|
appUpdateInfo: null,
|
|
|
|
socketConnected: false,
|
|
|
|
networkConnected: false,
|
2021-09-19 18:44:10 -05:00
|
|
|
networkConnectionType: null,
|
|
|
|
streamListener: null,
|
|
|
|
isFirstLoad: true,
|
2021-10-17 20:20:00 -05:00
|
|
|
hasStoragePermission: false,
|
|
|
|
selectedBook: null,
|
2021-10-28 09:37:31 -05:00
|
|
|
showReader: false,
|
|
|
|
downloadFolder: null,
|
2021-11-14 19:59:34 -06:00
|
|
|
mediaScanResults: {},
|
2021-11-19 10:29:26 -06:00
|
|
|
showSideDrawer: false,
|
|
|
|
bookshelfView: 'grid'
|
2021-09-01 20:07:11 -05:00
|
|
|
})
|
|
|
|
|
2021-09-12 18:37:08 -05:00
|
|
|
export const getters = {
|
|
|
|
playerIsOpen: (state) => {
|
|
|
|
return state.streamAudiobook || state.playingDownload
|
|
|
|
},
|
|
|
|
isAudiobookStreaming: (state) => id => {
|
|
|
|
return (state.streamAudiobook && state.streamAudiobook.id === id)
|
|
|
|
},
|
|
|
|
isAudiobookPlaying: (state) => id => {
|
|
|
|
return (state.playingDownload && state.playingDownload.id === id) || (state.streamAudiobook && state.streamAudiobook.id === id)
|
2021-11-14 19:59:34 -06:00
|
|
|
},
|
|
|
|
getAudiobookIdStreaming: state => {
|
|
|
|
return state.streamAudiobook ? state.streamAudiobook.id : null
|
2021-09-12 18:37:08 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-02 12:19:26 -05:00
|
|
|
export const actions = {}
|
2021-09-01 20:07:11 -05:00
|
|
|
|
|
|
|
export const mutations = {
|
2021-09-19 18:44:10 -05:00
|
|
|
setHasStoragePermission(state, val) {
|
|
|
|
state.hasStoragePermission = val
|
|
|
|
},
|
|
|
|
setIsFirstLoad(state, val) {
|
|
|
|
state.isFirstLoad = val
|
|
|
|
},
|
2021-09-04 12:31:00 -05:00
|
|
|
setAppUpdateInfo(state, info) {
|
|
|
|
state.appUpdateInfo = info
|
2021-09-02 12:19:26 -05:00
|
|
|
},
|
2021-09-01 20:07:11 -05:00
|
|
|
closeStream(state, audiobookId) {
|
|
|
|
if (state.streamAudiobook && state.streamAudiobook.id !== audiobookId) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
state.streamAudiobook = null
|
|
|
|
},
|
|
|
|
setPlayOnLoad(state, val) {
|
|
|
|
state.playOnLoad = val
|
|
|
|
},
|
|
|
|
setStreamAudiobook(state, audiobook) {
|
2021-09-12 18:37:08 -05:00
|
|
|
if (audiobook) {
|
|
|
|
state.playingDownload = null
|
|
|
|
}
|
|
|
|
Vue.set(state, 'streamAudiobook', audiobook)
|
|
|
|
if (state.streamListener) {
|
|
|
|
state.streamListener('stream', audiobook)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setPlayingDownload(state, download) {
|
|
|
|
if (download) {
|
|
|
|
state.streamAudiobook = null
|
|
|
|
}
|
|
|
|
Vue.set(state, 'playingDownload', download)
|
|
|
|
if (state.streamListener) {
|
|
|
|
state.streamListener('download', download)
|
|
|
|
}
|
2021-09-01 20:07:11 -05:00
|
|
|
},
|
|
|
|
setServerUrl(state, url) {
|
|
|
|
state.serverUrl = url
|
|
|
|
},
|
2021-09-12 18:37:08 -05:00
|
|
|
setSocketConnected(state, val) {
|
|
|
|
state.socketConnected = val
|
|
|
|
},
|
|
|
|
setNetworkStatus(state, val) {
|
|
|
|
state.networkConnected = val.connected
|
|
|
|
state.networkConnectionType = val.connectionType
|
|
|
|
},
|
|
|
|
setStreamListener(state, val) {
|
|
|
|
state.streamListener = val
|
|
|
|
},
|
|
|
|
removeStreamListener(state) {
|
|
|
|
state.streamListener = null
|
2021-10-17 20:20:00 -05:00
|
|
|
},
|
|
|
|
openReader(state, audiobook) {
|
|
|
|
state.selectedBook = audiobook
|
|
|
|
state.showReader = true
|
|
|
|
},
|
|
|
|
setShowReader(state, val) {
|
|
|
|
state.showReader = val
|
2021-10-28 09:37:31 -05:00
|
|
|
},
|
|
|
|
setDownloadFolder(state, val) {
|
|
|
|
state.downloadFolder = val
|
|
|
|
},
|
|
|
|
setMediaScanResults(state, val) {
|
|
|
|
state.mediaScanResults = val
|
2021-11-14 19:59:34 -06:00
|
|
|
},
|
|
|
|
setShowSideDrawer(state, val) {
|
|
|
|
state.showSideDrawer = val
|
2021-11-19 10:29:26 -06:00
|
|
|
},
|
|
|
|
setBookshelfView(state, val) {
|
|
|
|
state.bookshelfView = val
|
2021-09-01 20:07:11 -05:00
|
|
|
}
|
|
|
|
}
|