mirror of
https://github.com/NoCrypt/migu.git
synced 2026-01-11 20:10:22 +00:00
feat: sort continue watching by last updated
This commit is contained in:
parent
f88cca3e29
commit
5cf2357976
2 changed files with 11 additions and 4 deletions
|
|
@ -264,7 +264,6 @@ class AnilistClient {
|
|||
body: JSON.stringify({
|
||||
query: query.replace(/\s/g, '').replaceAll(' ', ' '),
|
||||
variables: {
|
||||
sort: 'TRENDING_DESC',
|
||||
page: 1,
|
||||
perPage: 30,
|
||||
status_in: '[CURRENT,PLANNING]',
|
||||
|
|
@ -550,7 +549,7 @@ class AnilistClient {
|
|||
variables.id = userId
|
||||
const query = /* js */`
|
||||
query($id: Int) {
|
||||
MediaListCollection(userId: $id, type: ANIME, forceSingleCompletedList: true) {
|
||||
MediaListCollection(userId: $id, type: ANIME, forceSingleCompletedList: true, sort: UPDATED_TIME_DESC) {
|
||||
lists {
|
||||
status,
|
||||
entries {
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ function createSections () {
|
|||
{
|
||||
title: 'Continue Watching',
|
||||
load: (page = 1, perPage = 50, variables = {}) => {
|
||||
const res = anilistClient.userLists.value.then(res => {
|
||||
const res = anilistClient.userLists.value.then(async res => {
|
||||
const mediaList = res.data.MediaListCollection.lists.reduce((filtered, { status, entries }) => {
|
||||
return (status === 'CURRENT' || status === 'REPEATING') ? filtered.concat(entries) : filtered
|
||||
}, [])
|
||||
|
|
@ -93,7 +93,15 @@ function createSections () {
|
|||
return media.mediaListEntry?.progress < media.nextAiringEpisode?.episode - 1
|
||||
}).map(({ media }) => media.id)
|
||||
if (!ids.length) return {}
|
||||
return anilistClient.searchIDS({ page, perPage, id: ids, ...SectionsManager.sanitiseObject(variables) })
|
||||
// if custom search is used, respect it, otherwise sort by last updated
|
||||
if (Object.values(variables).length !== 0) {
|
||||
return anilistClient.searchIDS({ page, perPage, id: ids, ...SectionsManager.sanitiseObject(variables) })
|
||||
}
|
||||
|
||||
const index = (page - 1) * perPage
|
||||
const idsRes = await anilistClient.searchIDS({ page, perPage, id: ids.slice(index, index + perPage), ...SectionsManager.sanitiseObject(variables) })
|
||||
idsRes.data.Page.media.sort((a, b) => ids.indexOf(a.id) - ids.indexOf(b.id))
|
||||
return idsRes
|
||||
})
|
||||
return SectionsManager.wrapResponse(res, perPage)
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue