mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-04 02:05:06 +02:00
Fix:Show only collections for selected library #1130
This commit is contained in:
parent
4cbc8676c6
commit
6f901defd6
3 changed files with 18 additions and 40 deletions
|
@ -10,9 +10,7 @@ export const state = () => ({
|
|||
collapseBookSeries: false
|
||||
},
|
||||
settingsListeners: [],
|
||||
collections: [],
|
||||
collectionsLoaded: false,
|
||||
collectionsListeners: []
|
||||
collections: []
|
||||
})
|
||||
|
||||
export const getters = {
|
||||
|
@ -113,20 +111,6 @@ export const actions = {
|
|||
console.error('Failed to update settings', error)
|
||||
return false
|
||||
})
|
||||
},
|
||||
loadCollections({ state, commit }) {
|
||||
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 []
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,11 +164,6 @@ export const mutations = {
|
|||
removeSettingsListener(state, listenerId) {
|
||||
state.settingsListeners = state.settingsListeners.filter(l => l.id !== listenerId)
|
||||
},
|
||||
setCollections(state, collections) {
|
||||
state.collectionsLoaded = true
|
||||
state.collections = collections
|
||||
state.collectionsListeners.forEach((listener) => listener.meth())
|
||||
},
|
||||
addUpdateCollection(state, collection) {
|
||||
var index = state.collections.findIndex(c => c.id === collection.id)
|
||||
if (index >= 0) {
|
||||
|
@ -192,18 +171,8 @@ export const mutations = {
|
|||
} else {
|
||||
state.collections.push(collection)
|
||||
}
|
||||
state.collectionsListeners.forEach((listener) => listener.meth())
|
||||
},
|
||||
removeCollection(state, collection) {
|
||||
state.collections = state.collections.filter(c => c.id !== collection.id)
|
||||
state.collectionsListeners.forEach((listener) => listener.meth())
|
||||
},
|
||||
addCollectionsListener(state, listener) {
|
||||
var index = state.collectionsListeners.findIndex(l => l.id === listener.id)
|
||||
if (index >= 0) state.collectionsListeners.splice(index, 1, listener)
|
||||
else state.collectionsListeners.push(listener)
|
||||
},
|
||||
removeCollectionsListener(state, listenerId) {
|
||||
state.collectionsListeners = state.collectionsListeners.filter(l => l.id !== listenerId)
|
||||
},
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue