Update get libraries API call to support updated response payload

This commit is contained in:
advplyr 2022-12-02 17:39:45 -06:00
parent 32dfb3b40a
commit a0faf3f7d4
3 changed files with 18 additions and 11 deletions

View file

@ -75,12 +75,15 @@ export const actions = {
return this.$axios
.$get(`/api/libraries`)
.then((data) => {
// TODO: Server release 2.2.9 changed response to an object. Remove after a few releases
const libraries = data.libraries || data
// Set current library if not already set or was not returned in results
if (data.length && (!state.currentLibraryId || !data.find(li => li.id == state.currentLibraryId))) {
commit('setCurrentLibrary', data[0].id)
if (libraries.length && (!state.currentLibraryId || !libraries.find(li => li.id == state.currentLibraryId))) {
commit('setCurrentLibrary', libraries[0].id)
}
commit('set', data)
commit('set', libraries)
commit('setLastLoad', Date.now())
return true
})