owntone-server/web-src/src/pages/PageMusicRecentlyAdded.vue

75 lines
1.7 KiB
Vue
Raw Normal View History

<template>
2022-02-19 06:18:01 +01:00
<div class="fd-page-with-tabs">
<tabs-music />
<content-with-heading>
<template #heading-left>
<p class="title is-4" v-text="$t('page.music.recently-added.title')" />
</template>
<template #content>
<list-albums :albums="recently_added" />
</template>
</content-with-heading>
</div>
</template>
<script>
2022-02-19 06:18:01 +01:00
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
2024-02-22 19:32:11 +01:00
import { GroupedList, byDateSinceToday } from '@/lib/GroupedList'
2022-02-19 06:18:01 +01:00
import ListAlbums from '@/components/ListAlbums.vue'
import store from '@/store'
import TabsMusic from '@/components/TabsMusic.vue'
import webapi from '@/webapi'
2022-02-19 06:18:01 +01:00
const dataObject = {
load(to) {
const limit = store.getters.settings_option_recently_added_limit
return webapi.search({
type: 'album',
expression:
'media_kind is music having track_count > 3 order by time_added desc',
2023-11-24 15:48:29 +01:00
limit
})
},
set(vm, response) {
2024-02-22 19:32:11 +01:00
vm.recently_added = new GroupedList(response.data.albums)
vm.recently_added.group(
byDateSinceToday('time_added', {
direction: 'desc'
})
)
}
}
export default {
name: 'PageMusicRecentlyAdded',
components: { ContentWithHeading, TabsMusic, ListAlbums },
beforeRouteEnter(to, from, next) {
dataObject.load(to).then((response) => {
next((vm) => dataObject.set(vm, response))
})
},
beforeRouteUpdate(to, from, next) {
if (!this.recently_added.isEmpty()) {
next()
return
}
const vm = this
dataObject.load(to).then((response) => {
dataObject.set(vm, response)
next()
})
},
data() {
return {
2024-02-22 19:32:11 +01:00
recently_added: new GroupedList()
}
}
}
</script>
<style></style>