mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-07 04:18:48 +02:00
Finish lazy bookshelf,Fix:Async sql db,Fix:Load user progress
This commit is contained in:
+9
-35
@@ -12,9 +12,7 @@ export const state = () => ({
|
||||
bookshelfCoverSize: 120
|
||||
},
|
||||
settingsListeners: [],
|
||||
userAudiobooksListeners: [],
|
||||
collections: [],
|
||||
collectionsLoaded: false
|
||||
userAudiobooksListeners: []
|
||||
})
|
||||
|
||||
export const getters = {
|
||||
@@ -33,9 +31,6 @@ export const getters = {
|
||||
},
|
||||
getFilterOrderKey: (state) => {
|
||||
return Object.values(state.settings).join('-')
|
||||
},
|
||||
getCollection: state => id => {
|
||||
return state.collections.find(c => c.id === id)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,23 +56,14 @@ export const actions = {
|
||||
commit('setSettings', payload)
|
||||
}
|
||||
},
|
||||
loadUserCollections({ state, commit }) {
|
||||
if (!this.$server.connected) {
|
||||
console.error('Not loading collections - not connected')
|
||||
return []
|
||||
async loadOfflineUserAudiobookData({ state, commit }) {
|
||||
var localUserAudiobookData = await this.$sqlStore.getAllUserAudiobookData() || []
|
||||
if (localUserAudiobookData.length) {
|
||||
console.log('loadOfflineUserAudiobookData found', localUserAudiobookData.length, 'user audiobook data')
|
||||
commit('setAllUserAudiobookData', localUserAudiobookData)
|
||||
} else {
|
||||
console.log('loadOfflineUserAudiobookData No user audiobook data')
|
||||
}
|
||||
if (state.collectionsLoaded) {
|
||||
console.log('Collections already loaded')
|
||||
return state.collections
|
||||
}
|
||||
|
||||
return this.$axios.$get('/api/collections').then((collections) => {
|
||||
commit('setCollections', collections)
|
||||
return collections
|
||||
}).catch((error) => {
|
||||
console.error('Failed to get collections', error)
|
||||
return []
|
||||
})
|
||||
},
|
||||
async syncUserAudiobookData({ state, commit }) {
|
||||
if (!state.user) {
|
||||
@@ -167,17 +153,5 @@ export const mutations = {
|
||||
},
|
||||
removeUserAudiobookListener(state, listenerId) {
|
||||
state.userAudiobooksListeners = state.userAudiobooksListeners.filter(l => l.id !== listenerId)
|
||||
},
|
||||
setCollections(state, collections) {
|
||||
state.collections = collections
|
||||
state.collectionsLoaded = true
|
||||
},
|
||||
addUpdateCollection(state, collection) {
|
||||
var index = state.collections.findIndex(c => c.id === collection.id)
|
||||
if (index >= 0) {
|
||||
state.collections.splice(index, 1, collection)
|
||||
} else {
|
||||
state.collections.push(collection)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user