audiobookshelf/client/pages/library/_library/bookshelf/_id.vue

54 lines
1.4 KiB
Vue
Raw Normal View History

2021-09-23 03:40:35 +02:00
<template>
<div class="page" :class="streamLibraryItem ? 'streaming' : ''">
2022-10-29 00:27:06 +02:00
<app-book-shelf-toolbar :page="id || ''" />
<app-lazy-bookshelf :page="id || ''" />
2021-09-23 03:40:35 +02:00
</div>
</template>
<script>
export default {
async asyncData({ params, query, store, app, redirect }) {
var libraryId = params.library
var libraryData = await store.dispatch('libraries/fetch', libraryId)
if (!libraryData) {
return redirect('/oops?message=Library not found')
}
2022-10-29 18:17:51 +02:00
// Set series sort by
2022-10-29 22:33:38 +02:00
if (params.id === 'series') {
console.log('Series page', query)
if (query.sort) {
store.commit('libraries/setSeriesSortBy', query.sort)
store.commit('libraries/setSeriesSortDesc', !!query.desc)
}
if (query.filter) {
console.log('has filter', query.filter)
store.commit('libraries/setSeriesFilterBy', query.filter)
}
} else if (query.filter) {
store.dispatch('user/updateUserSettings', { filterBy: query.filter })
}
// Redirect podcast libraries
const library = libraryData.library
if (library.mediaType === 'podcast' && (params.id === 'collections' || params.id === 'series')) {
return redirect(`/library/${libraryId}`)
}
2021-09-23 03:40:35 +02:00
return {
2021-12-02 02:07:03 +01:00
id: params.id || '',
libraryId
2021-09-23 03:40:35 +02:00
}
},
data() {
2022-10-29 00:27:06 +02:00
return {}
2021-09-23 03:40:35 +02:00
},
computed: {
streamLibraryItem() {
return this.$store.state.streamLibraryItem
2021-09-23 03:40:35 +02:00
}
},
2021-12-02 02:07:03 +01:00
methods: {}
2021-09-23 03:40:35 +02:00
}
</script>