mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-19 15:23:36 +00:00
Pagination component now watches page/perPage via useListContext and calls abortAllInFlight() when either changes, freeing the browser connection pool immediately for the next page's data request. Also adds empty placeholder style to CoverArtAvatar so it renders as a clean transparent area while loading instead of the default person icon.
19 lines
581 B
React
19 lines
581 B
React
import React, { useEffect, useRef } from 'react'
|
|
import { Pagination as RAPagination, useListContext } from 'react-admin'
|
|
import { abortAllInFlight } from './useImageUrl'
|
|
|
|
export const Pagination = (props) => {
|
|
const { page, perPage } = useListContext()
|
|
const prevRef = useRef({ page, perPage })
|
|
|
|
useEffect(() => {
|
|
const prev = prevRef.current
|
|
if (prev.page !== page || prev.perPage !== perPage) {
|
|
abortAllInFlight()
|
|
prevRef.current = { page, perPage }
|
|
}
|
|
}, [page, perPage])
|
|
|
|
return <RAPagination rowsPerPageOptions={[15, 25, 50]} {...props} />
|
|
}
|