Some checks are pending
E2E / Playwright e2e (push) Waiting to run
- Added SessionGuard component to manage session expiration and online status. - Updated AuthProvider to streamline session fetching and handling. - Introduced IdentityProvidersSection for managing OAuth, SAML, and LDAP identity providers. - Implemented identity provider guides for easier configuration. - Enhanced mail settings with infinite scroll option for improved user experience. - Updated global styles and layout components for better consistency across the application.
52 lines
1.1 KiB
TypeScript
52 lines
1.1 KiB
TypeScript
"use client"
|
||
|
||
import { useEffect, type RefObject } from "react"
|
||
|
||
type UseMailListInfiniteScrollOptions = {
|
||
enabled: boolean
|
||
sentinelRef: RefObject<HTMLElement | null>
|
||
scrollRootRef: RefObject<HTMLElement | null>
|
||
hasMore: boolean
|
||
isLoadingMore: boolean
|
||
onLoadMore: () => void
|
||
/** Charge avant le bas visible pour éviter l’attente au scroll. */
|
||
rootMargin?: string
|
||
}
|
||
|
||
export function useMailListInfiniteScroll({
|
||
enabled,
|
||
sentinelRef,
|
||
scrollRootRef,
|
||
hasMore,
|
||
isLoadingMore,
|
||
onLoadMore,
|
||
rootMargin = "480px",
|
||
}: UseMailListInfiniteScrollOptions) {
|
||
useEffect(() => {
|
||
if (!enabled || !hasMore) return
|
||
|
||
const sentinel = sentinelRef.current
|
||
const root = scrollRootRef.current
|
||
if (!sentinel || !root) return
|
||
|
||
const observer = new IntersectionObserver(
|
||
([entry]) => {
|
||
if (!entry?.isIntersecting || isLoadingMore) return
|
||
onLoadMore()
|
||
},
|
||
{ root, rootMargin, threshold: 0 }
|
||
)
|
||
|
||
observer.observe(sentinel)
|
||
return () => observer.disconnect()
|
||
}, [
|
||
enabled,
|
||
hasMore,
|
||
isLoadingMore,
|
||
onLoadMore,
|
||
rootMargin,
|
||
sentinelRef,
|
||
scrollRootRef,
|
||
])
|
||
}
|