fix(admin): prevent excessive polling in notifications (#12868)
Co-authored-by: Your Name <you@example.com>
This commit is contained in:
@@ -77,6 +77,7 @@ export const InfiniteList = <
|
||||
startObserver.current = new IntersectionObserver(
|
||||
(entries) => {
|
||||
if (entries[0].isIntersecting && hasPreviousPage) {
|
||||
startObserver.current?.disconnect()
|
||||
fetchPreviousPage()
|
||||
}
|
||||
},
|
||||
@@ -88,6 +89,7 @@ export const InfiniteList = <
|
||||
endObserver.current = new IntersectionObserver(
|
||||
(entries) => {
|
||||
if (entries[0].isIntersecting && hasNextPage) {
|
||||
endObserver.current?.disconnect()
|
||||
fetchNextPage()
|
||||
}
|
||||
},
|
||||
@@ -97,8 +99,12 @@ export const InfiniteList = <
|
||||
)
|
||||
|
||||
// Register the new observers to observe the new first and last children
|
||||
startObserver.current?.observe(parentRef.current!.firstChild as Element)
|
||||
endObserver.current?.observe(parentRef.current!.lastChild as Element)
|
||||
if (parentRef.current?.firstChild) {
|
||||
startObserver.current?.observe(parentRef.current.firstChild as Element)
|
||||
}
|
||||
if (parentRef.current?.lastChild) {
|
||||
endObserver.current?.observe(parentRef.current.lastChild as Element)
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the old observers
|
||||
|
||||
Reference in New Issue
Block a user