Offline support, downloading, syncing progress

This commit is contained in:
advplyr 2021-09-12 18:37:08 -05:00
parent e97218f2e8
commit a412c9d359
37 changed files with 2836 additions and 201 deletions

View file

@ -1,12 +1,29 @@
import Vue from 'vue'
export const state = () => ({
streamAudiobook: null,
playingDownload: null,
playOnLoad: false,
serverUrl: null,
user: null,
appUpdateInfo: null
appUpdateInfo: null,
socketConnected: false,
networkConnected: false,
networkConnectionType: 'unknown',
streamListener: null
})
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)
}
}
export const actions = {}
export const mutations = {
@ -23,12 +40,37 @@ export const mutations = {
state.playOnLoad = val
},
setStreamAudiobook(state, audiobook) {
state.streamAudiobook = audiobook
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)
}
},
setServerUrl(state, url) {
state.serverUrl = url
},
setUser(state, user) {
state.user = user
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
}
}