fix authors list pages
This commit is contained in:
parent
507cfebd48
commit
e34aa5e70b
|
@ -28,6 +28,7 @@ export const AuthorsList = (props: Props) => {
|
|||
const fetchAuthors = async (queryType: Props['query'], page: number) => {
|
||||
setLoading(true)
|
||||
const offset = PAGE_SIZE * page
|
||||
|
||||
const result = await apiClient.loadAuthorsBy({
|
||||
by: { order: queryType },
|
||||
limit: PAGE_SIZE,
|
||||
|
@ -35,12 +36,11 @@ export const AuthorsList = (props: Props) => {
|
|||
})
|
||||
|
||||
if (queryType === 'shouts') {
|
||||
setAuthorsByShouts((prev) => [...prev, ...result])
|
||||
setAuthorsByShouts((prev) => [prev, ...result])
|
||||
} else {
|
||||
setAuthorsByFollowers((prev) => [...prev, ...result])
|
||||
setAuthorsByFollowers((prev) => [prev, ...result])
|
||||
}
|
||||
setLoading(false)
|
||||
return result
|
||||
}
|
||||
|
||||
const loadMoreAuthors = () => {
|
||||
|
@ -73,7 +73,7 @@ export const AuthorsList = (props: Props) => {
|
|||
// })
|
||||
|
||||
createEffect(() => {
|
||||
setAllLoaded(authorsByShouts().length === authorsList.length)
|
||||
setAllLoaded(props.allAuthorsLength === authorsList.length)
|
||||
})
|
||||
|
||||
return (
|
||||
|
@ -96,6 +96,7 @@ export const AuthorsList = (props: Props) => {
|
|||
<div class="row">
|
||||
<div class="col-lg-20 col-xl-18">
|
||||
<div class={styles.action}>
|
||||
<p>{`${loading()}`}</p>
|
||||
<Show when={!loading() && authorsList().length > 0 && !allLoaded()}>
|
||||
<Button value={t('Load more')} onClick={loadMoreAuthors} />
|
||||
</Show>
|
||||
|
|
Loading…
Reference in New Issue
Block a user