mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-10 05:08:11 -05:00
[web-src] recently added - retreive all data in one async go
This commit is contained in:
parent
5eeadd3f1b
commit
08397058f1
@ -93,15 +93,36 @@ import webapi from '@/webapi'
|
|||||||
|
|
||||||
const browseData = {
|
const browseData = {
|
||||||
load: function (to) {
|
load: function (to) {
|
||||||
return webapi.search({
|
const recentlyAddedLimit = 100
|
||||||
type: 'album',
|
return Promise.all([
|
||||||
expression: 'time_added after today and media_kind is music order by time_added desc',
|
webapi.search({
|
||||||
limit: 100
|
type: 'album',
|
||||||
})
|
expression: 'time_added after today and media_kind is music order by time_added desc',
|
||||||
|
limit: recentlyAddedLimit
|
||||||
|
}),
|
||||||
|
webapi.search({
|
||||||
|
type: 'album',
|
||||||
|
expression: 'time_added after this week and media_kind is music order by time_added desc',
|
||||||
|
limit: recentlyAddedLimit
|
||||||
|
}),
|
||||||
|
webapi.search({
|
||||||
|
type: 'album',
|
||||||
|
expression: 'time_added after last month and media_kind is music order by time_added desc',
|
||||||
|
limit: recentlyAddedLimit
|
||||||
|
}),
|
||||||
|
webapi.search({
|
||||||
|
type: 'album',
|
||||||
|
expression: 'time_added before last month and media_kind is music order by time_added desc',
|
||||||
|
limit: recentlyAddedLimit
|
||||||
|
})
|
||||||
|
])
|
||||||
},
|
},
|
||||||
|
|
||||||
set: function (vm, response) {
|
set: function (vm, response) {
|
||||||
vm.recently_added_today = response.data.albums
|
vm.recently_added_today = response[0].data.albums
|
||||||
|
vm.recently_added_week = response[1].data.albums
|
||||||
|
vm.recently_added_month = response[2].data.albums
|
||||||
|
vm.recently_added_older = response[3].data.albums
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,13 +130,13 @@ export default {
|
|||||||
name: 'PageBrowseType',
|
name: 'PageBrowseType',
|
||||||
mixins: [LoadDataBeforeEnterMixin(browseData)],
|
mixins: [LoadDataBeforeEnterMixin(browseData)],
|
||||||
components: { ContentWithHeading, TabsMusic, ListAlbums, ModalDialogAlbums },
|
components: { ContentWithHeading, TabsMusic, ListAlbums, ModalDialogAlbums },
|
||||||
|
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
recently_added_today: { items: [] },
|
recently_added_today: { items: [] },
|
||||||
recently_added_week: { items: [] },
|
recently_added_week: { items: [] },
|
||||||
recently_added_month: { items: [] },
|
recently_added_month: { items: [] },
|
||||||
recently_added_older: { items: [] },
|
recently_added_older: { items: [] },
|
||||||
limit: 100,
|
|
||||||
|
|
||||||
show_modal_today: false,
|
show_modal_today: false,
|
||||||
show_modal_week: false,
|
show_modal_week: false,
|
||||||
@ -124,38 +145,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
created () {
|
|
||||||
if (this.recently_added < this.limit) {
|
|
||||||
webapi.search({
|
|
||||||
type: 'album',
|
|
||||||
expression: 'time_added after this week and media_kind is music order by time_added desc',
|
|
||||||
limit: this.limit - this.recently_added
|
|
||||||
}).then(({ data }) => {
|
|
||||||
this.recently_added_week = data.albums
|
|
||||||
|
|
||||||
if (this.recently_added < this.limit) {
|
|
||||||
webapi.search({
|
|
||||||
type: 'album',
|
|
||||||
expression: 'time_added after last month and media_kind is music order by time_added desc',
|
|
||||||
limit: this.limit - this.recently_added
|
|
||||||
}).then(({ data }) => {
|
|
||||||
this.recently_added_month = data.albums
|
|
||||||
|
|
||||||
if (this.recently_added < this.limit) {
|
|
||||||
webapi.search({
|
|
||||||
type: 'album',
|
|
||||||
expression: 'time_added before last month and media_kind is music order by time_added desc',
|
|
||||||
limit: this.limit - this.recently_added
|
|
||||||
}).then(({ data }) => {
|
|
||||||
this.recently_added_older = data.albums
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
show_recent_today () {
|
show_recent_today () {
|
||||||
return this.recently_added_today.items.length > 0
|
return this.recently_added_today.items.length > 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user