fix(admin): prevent excessive polling in notifications (#12868)

Co-authored-by: Your Name <you@example.com>
This commit is contained in:
Jessy LANGE
2025-07-03 13:09:13 +02:00
committed by GitHub
parent 6aa89b62b9
commit eed72db502

View File

@@ -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