Fix:Remove collections when removing library

This commit is contained in:
advplyr 2022-11-11 17:44:19 -06:00
parent 6f901defd6
commit 28feed6ea2
6 changed files with 55 additions and 38 deletions

View file

@ -11,7 +11,8 @@ export const state = () => ({
filterData: null,
seriesSortBy: 'name',
seriesSortDesc: false,
seriesFilterBy: 'all'
seriesFilterBy: 'all',
collections: []
})
export const getters = {
@ -55,6 +56,9 @@ export const getters = {
getBookCoverAspectRatio: (state, getters) => {
if (!getters.getCurrentLibrarySettings || isNaN(getters.getCurrentLibrarySettings.coverAspectRatio)) return 1
return getters.getCurrentLibrarySettings.coverAspectRatio === Constants.BookCoverAspectRatio.STANDARD ? 1.6 : 1
},
getCollection: state => id => {
return state.collections.find(c => c.id === id)
}
}
@ -111,6 +115,7 @@ export const actions = {
commit('setLibraryIssues', issues)
commit('setLibraryFilterData', filterData)
commit('setCurrentLibrary', libraryId)
commit('setCollections', [])
return data
})
.catch((error) => {
@ -301,5 +306,19 @@ export const mutations = {
},
setSeriesFilterBy(state, filterBy) {
state.seriesFilterBy = filterBy
},
setCollections(state, collections) {
state.collections = collections
},
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)
}
},
removeCollection(state, collection) {
state.collections = state.collections.filter(c => c.id !== collection.id)
}
}