mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
36 lines
824 B
JavaScript
36 lines
824 B
JavaScript
|
|
export const state = () => ({
|
|
downloads: []
|
|
})
|
|
|
|
export const getters = {
|
|
getDownloads: (state) => (audiobookId) => {
|
|
return state.downloads.filter(d => d.audiobookId === audiobookId)
|
|
}
|
|
}
|
|
|
|
export const actions = {
|
|
|
|
}
|
|
|
|
export const mutations = {
|
|
addUpdateDownload(state, download) {
|
|
// Remove older downloads of matching type
|
|
state.downloads = state.downloads.filter(d => {
|
|
if (d.id !== download.id && d.type === download.type) {
|
|
return false
|
|
}
|
|
return true
|
|
})
|
|
|
|
var index = state.downloads.findIndex(d => d.id === download.id)
|
|
if (index >= 0) {
|
|
state.downloads.splice(index, 1, download)
|
|
} else {
|
|
state.downloads.push(download)
|
|
}
|
|
},
|
|
removeDownload(state, download) {
|
|
state.downloads = state.downloads.filter(d => d.id !== download.id)
|
|
}
|
|
} |