Fix: android auto requirements, Change: New UI #33

This commit is contained in:
advplyr
2021-11-14 19:59:34 -06:00
parent bf8e48fd27
commit 0abefbd9bc
43 changed files with 2336 additions and 308 deletions
+35 -1
View File
@@ -30,7 +30,11 @@ export const getters = {
var filter = decode(filterBy.replace(`${group}.`, ''))
if (group === 'genres') filtered = filtered.filter(ab => ab.book && ab.book.genres.includes(filter))
else if (group === 'tags') filtered = filtered.filter(ab => ab.tags.includes(filter))
else if (group === 'series') filtered = filtered.filter(ab => ab.book && ab.book.series === filter)
else if (group === 'series') {
if (filter === 'No Series') filtered = filtered.filter(ab => ab.book && !ab.book.series)
else filtered = filtered.filter(ab => ab.book && ab.book.series === filter)
}
// else if (group === 'series') filtered = filtered.filter(ab => ab.book && ab.book.series === filter)
else if (group === 'authors') filtered = filtered.filter(ab => ab.book && ab.book.author === filter)
else if (group === 'progress') {
filtered = filtered.filter(ab => {
@@ -67,6 +71,36 @@ export const getters = {
})
}
},
getSeriesGroups: (state, getters, rootState) => () => {
var series = {}
state.audiobooks.forEach((audiobook) => {
if (audiobook.book && audiobook.book.series) {
if (series[audiobook.book.series]) {
var bookLastUpdate = audiobook.book.lastUpdate
if (bookLastUpdate > series[audiobook.book.series].lastUpdate) series[audiobook.book.series].lastUpdate = bookLastUpdate
series[audiobook.book.series].books.push(audiobook)
} else {
series[audiobook.book.series] = {
type: 'series',
name: audiobook.book.series || '',
books: [audiobook],
lastUpdate: audiobook.book.lastUpdate
}
}
}
})
var seriesArray = Object.values(series).map((_series) => {
_series.books = sort(_series.books)['asc']((ab) => {
return ab.book && ab.book.volumeNumber && !isNaN(ab.book.volumeNumber) ? Number(ab.book.volumeNumber) : null
})
return _series
})
if (state.keywordFilter) {
const keywordFilter = state.keywordFilter.toLowerCase()
return seriesArray.filter((_series) => _series.name.toLowerCase().includes(keywordFilter))
}
return seriesArray
},
getUniqueAuthors: (state) => {
var _authors = state.audiobooks.filter(ab => !!(ab.book && ab.book.author)).map(ab => ab.book.author)
return [...new Set(_authors)]
+8 -1
View File
@@ -15,7 +15,8 @@ export const state = () => ({
selectedBook: null,
showReader: false,
downloadFolder: null,
mediaScanResults: {}
mediaScanResults: {},
showSideDrawer: false
})
export const getters = {
@@ -27,6 +28,9 @@ export const getters = {
},
isAudiobookPlaying: (state) => id => {
return (state.playingDownload && state.playingDownload.id === id) || (state.streamAudiobook && state.streamAudiobook.id === id)
},
getAudiobookIdStreaming: state => {
return state.streamAudiobook ? state.streamAudiobook.id : null
}
}
@@ -97,5 +101,8 @@ export const mutations = {
},
setMediaScanResults(state, val) {
state.mediaScanResults = val
},
setShowSideDrawer(state, val) {
state.showSideDrawer = val
}
}
+37 -2
View File
@@ -12,7 +12,9 @@ export const state = () => ({
bookshelfCoverSize: 120
},
settingsListeners: [],
userAudiobooksListeners: []
userAudiobooksListeners: [],
collections: [],
collectionsLoaded: false
})
export const getters = {
@@ -38,6 +40,9 @@ export const getters = {
},
getFilterOrderKey: (state) => {
return Object.values(state.settings).join('-')
},
getCollection: state => id => {
return state.collections.find(c => c.id === id)
}
}
@@ -62,6 +67,24 @@ export const actions = {
console.log('Update settings without server')
commit('setSettings', payload)
}
},
loadUserCollections({ state, commit }) {
if (!this.$server.connected) {
console.error('Not loading collections - not connected')
return []
}
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 []
})
}
}
@@ -120,5 +143,17 @@ 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)
}
},
}