mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-03 16:52:10 +08:00
修复潜在列表加载问题
This commit is contained in:
parent
b33f848589
commit
fe78fc251a
@ -49,7 +49,10 @@ export const search = async(text: string, page: number, sourceId: Source): Promi
|
||||
return (musicSdk[sourceId]?.musicSearch.search(text, page, listInfo.limit).then((data: SearchResult) => {
|
||||
if (key != listInfo.key) return []
|
||||
return setListInfo(data, page, text)
|
||||
}) ?? Promise.reject(new Error('source not found: ' + sourceId)))
|
||||
}) ?? Promise.reject(new Error('source not found: ' + sourceId))).catch((err: any) => {
|
||||
if (listInfo.list.length && page == 1) clearListInfo(sourceId)
|
||||
throw err
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,9 @@ export const search = async(text: string, page: number, sourceId: Source): Promi
|
||||
return ((musicSdk[sourceId]?.songList.search(text, page, listInfo.limit) as Promise<SearchResult>).then((data: SearchResult) => {
|
||||
if (key != listInfo.key) return []
|
||||
return setListInfo(data, page, text)
|
||||
}) ?? Promise.reject(new Error('source not found: ' + sourceId)))
|
||||
}) ?? Promise.reject(new Error('source not found: ' + sourceId))).catch((err: any) => {
|
||||
if (listInfo.list.length && page == 1) clearListInfo(sourceId)
|
||||
throw err
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,8 @@ export default ({ musicInfo, onUpdateTotal }: {
|
||||
}
|
||||
const handleListLoadMore = () => {
|
||||
if (listInfo.current.isLoading || listInfo.current.isEnd) return
|
||||
const page = listInfo.current.page + 1
|
||||
const list = listRef.current?.getList() ?? []
|
||||
const page = list.length ? listInfo.current.page + 1 : 1
|
||||
listRef.current?.setStatus('loading')
|
||||
void handleGetComment(musicInfo, page).then(({ comments }) => {
|
||||
let isEnd = page >= listInfo.current.maxPage
|
||||
|
@ -44,7 +44,8 @@ export default ({ musicInfo, onUpdateTotal }: {
|
||||
const handleListLoadMore = () => {
|
||||
console.log('load')
|
||||
if (listInfo.current.isLoading || listInfo.current.isEnd) return
|
||||
const page = listInfo.current.page + 1
|
||||
const list = listRef.current?.getList() ?? []
|
||||
const page = list.length ? listInfo.current.page + 1 : 1
|
||||
listRef.current?.setStatus('loading')
|
||||
void handleGetComment(musicInfo, page).then(({ comments }) => {
|
||||
let isEnd = page >= listInfo.current.maxPage
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react'
|
||||
import OnlineList, { type OnlineListType, type OnlineListProps } from '@/components/OnlineList'
|
||||
import { getListDetail, setListDetail, setListDetailInfo } from '@/core/leaderboard'
|
||||
import { clearListDetail, getListDetail, setListDetail, setListDetailInfo } from '@/core/leaderboard'
|
||||
import boardState from '@/store/leaderboard/state'
|
||||
import { handlePlay } from './listAction'
|
||||
|
||||
@ -37,6 +37,7 @@ export default forwardRef<MusicListType, {}>((props, ref) => {
|
||||
listRef.current?.setStatus(boardState.listDetailInfo.maxPage == page ? 'end' : 'idle')
|
||||
})
|
||||
}).catch(() => {
|
||||
if (boardState.listDetailInfo.list.length && page == 1) clearListDetail()
|
||||
listRef.current?.setStatus('error')
|
||||
})
|
||||
}
|
||||
@ -65,6 +66,7 @@ export default forwardRef<MusicListType, {}>((props, ref) => {
|
||||
listRef.current?.setList(result.list)
|
||||
listRef.current?.setStatus(boardState.listDetailInfo.maxPage == page ? 'end' : 'idle')
|
||||
}).catch(() => {
|
||||
if (boardState.listDetailInfo.list.length && page == 1) clearListDetail()
|
||||
listRef.current?.setStatus('error')
|
||||
})
|
||||
}
|
||||
@ -77,6 +79,7 @@ export default forwardRef<MusicListType, {}>((props, ref) => {
|
||||
listRef.current?.setList(result.list)
|
||||
listRef.current?.setStatus(boardState.listDetailInfo.maxPage == page ? 'end' : 'idle')
|
||||
}).catch(() => {
|
||||
if (boardState.listDetailInfo.list.length && page == 1) clearListDetail()
|
||||
listRef.current?.setStatus('error')
|
||||
})
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react'
|
||||
import Songlist, { type SonglistProps, type SonglistType } from './components/Songlist'
|
||||
import { getList, setList, setListInfo } from '@/core/songlist'
|
||||
import { clearList, getList, setList, setListInfo } from '@/core/songlist'
|
||||
import songlistState from '@/store/songlist/state'
|
||||
import { type Source } from '@/store/songlist/state'
|
||||
|
||||
@ -32,6 +32,7 @@ export default forwardRef<ListType, {}>((props, ref) => {
|
||||
listRef.current?.setStatus(songlistState.listInfo.maxPage == page ? 'end' : 'idle')
|
||||
})
|
||||
}).catch(() => {
|
||||
if (songlistState.listInfo.list.length && page == 1) clearList()
|
||||
listRef.current?.setStatus('error')
|
||||
})
|
||||
}
|
||||
@ -55,6 +56,7 @@ export default forwardRef<ListType, {}>((props, ref) => {
|
||||
listRef.current?.setList(result.list)
|
||||
listRef.current?.setStatus(songlistState.listInfo.maxPage == page ? 'end' : 'idle')
|
||||
}).catch(() => {
|
||||
if (songlistState.listInfo.list.length && page == 1) clearList()
|
||||
listRef.current?.setStatus('error')
|
||||
})
|
||||
}
|
||||
@ -67,6 +69,7 @@ export default forwardRef<ListType, {}>((props, ref) => {
|
||||
listRef.current?.setList(result.list)
|
||||
listRef.current?.setStatus(songlistState.listInfo.maxPage == page ? 'end' : 'idle')
|
||||
}).catch(() => {
|
||||
if (songlistState.listInfo.list.length && page == 1) clearList()
|
||||
listRef.current?.setStatus('error')
|
||||
})
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef } from 'react'
|
||||
import OnlineList, { type OnlineListType, type OnlineListProps } from '@/components/OnlineList'
|
||||
import { getListDetail, setListDetail, setListDetailInfo } from '@/core/songlist'
|
||||
import { clearListDetail, getListDetail, setListDetail, setListDetailInfo } from '@/core/songlist'
|
||||
import songlistState from '@/store/songlist/state'
|
||||
import { handlePlay } from './listAction'
|
||||
import Header, { type HeaderType } from './Header'
|
||||
@ -55,6 +55,7 @@ export default forwardRef<MusicListType, MusicListProps>(({ componentId }, ref)
|
||||
listRef.current?.setStatus(songlistState.listDetailInfo.maxPage == page ? 'end' : 'idle')
|
||||
})
|
||||
}).catch(() => {
|
||||
if (songlistState.listDetailInfo.list.length && page == 1) clearListDetail()
|
||||
listRef.current?.setStatus('error')
|
||||
})
|
||||
}
|
||||
@ -83,6 +84,7 @@ export default forwardRef<MusicListType, MusicListProps>(({ componentId }, ref)
|
||||
listRef.current?.setList(result.list)
|
||||
listRef.current?.setStatus(songlistState.listDetailInfo.maxPage == page ? 'end' : 'idle')
|
||||
}).catch(() => {
|
||||
if (songlistState.listDetailInfo.list.length && page == 1) clearListDetail()
|
||||
listRef.current?.setStatus('error')
|
||||
})
|
||||
}
|
||||
@ -95,6 +97,7 @@ export default forwardRef<MusicListType, MusicListProps>(({ componentId }, ref)
|
||||
listRef.current?.setList(result.list)
|
||||
listRef.current?.setStatus(songlistState.listDetailInfo.maxPage == page ? 'end' : 'idle')
|
||||
}).catch(() => {
|
||||
if (songlistState.listDetailInfo.list.length && page == 1) clearListDetail()
|
||||
listRef.current?.setStatus('error')
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user