web: fix lint regression from Load-all — lift sweep state into useDashboardSessions

The Load-all button reconstructed 'sweep running' locally via a
set-state-in-effect on loadingMore, adding a 116th react-hooks warning
over the 115 cap. The hook already knows loadMore vs loadAll apart, so
expose loadingAll from useDashboardSessions and drop the local state and
effect entirely.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Oliver Kieselbach
2026-08-06 14:39:51 +02:00
parent 90294455e0
commit 7636a00e24
3 changed files with 12 additions and 9 deletions
@@ -77,6 +77,7 @@ interface SessionTableProps {
onSessionsPerPageChange: (value: number) => void;
hasMore: boolean;
loadingMore: boolean;
loadingAll: boolean;
onLoadAll: () => void;
adminMode: boolean;
globalAdminMode: boolean;
@@ -127,6 +128,7 @@ export function SessionTable({
onSessionsPerPageChange,
hasMore,
loadingMore,
loadingAll,
onLoadAll,
adminMode,
globalAdminMode,
@@ -158,12 +160,6 @@ export function SessionTable({
const searchDropdownRef = useRef<HTMLDivElement>(null);
const [showSearchSuggestions, setShowSearchSuggestions] = useState(false);
const [searchSelectedIndex, setSearchSelectedIndex] = useState(-1);
// Distinguishes a running "Load all" sweep from a single Next-click batch —
// both surface as loadingMore, but only the sweep should relabel the button.
const [loadAllActive, setLoadAllActive] = useState(false);
useEffect(() => {
if (!loadingMore) setLoadAllActive(false);
}, [loadingMore]);
// Fuzzy-match sessions by multiple fields for search dropdown (two-phase: exact then Levenshtein)
interface SearchSuggestion {
@@ -741,14 +737,13 @@ export function SessionTable({
<button
onClick={() => {
trackEvent("session_load_all_clicked", { loadedSessions: sessions.length });
setLoadAllActive(true);
onLoadAll();
}}
disabled={loadingMore}
className="text-sm font-medium text-green-700 hover:text-green-800 hover:underline transition-colors disabled:opacity-50 disabled:cursor-not-allowed disabled:no-underline"
title="Fetch all remaining sessions from the server so sorting and filters cover everything"
>
{loadAllActive ? "Loading all..." : "Load all"}
{loadingAll ? "Loading all..." : "Load all"}
</button>
)}
</div>
@@ -68,6 +68,7 @@ export interface UseDashboardSessionsReturn {
loading: boolean;
hasMore: boolean;
loadingMore: boolean;
loadingAll: boolean;
refetch: () => void;
refetchWith: (tenantIdOverride: string) => void;
loadMore: () => void;
@@ -102,6 +103,9 @@ export function useDashboardSessions({
const [loading, setLoading] = useState(true);
const [hasMore, setHasMore] = useState(false);
const [loadingMore, setLoadingMore] = useState(false);
// True only while the progressive loadAll() sweep runs — loadMore() sets just
// loadingMore. Lets the UI label a full sweep differently from a single batch.
const [loadingAll, setLoadingAll] = useState(false);
const [continuation, setContinuation] = useState<string | null>(null);
// Refs for SignalR handlers to access current filter state without restarting subscriptions
@@ -343,6 +347,7 @@ export function useDashboardSessions({
fetchLockRef.current = true;
const myToken = ++loadAllTokenRef.current;
setLoadingMore(true);
setLoadingAll(true);
try {
let currentContinuation: string | null = continuationRef.current;
while (currentContinuation && loadAllTokenRef.current === myToken) {
@@ -357,6 +362,7 @@ export function useDashboardSessions({
} finally {
fetchLockRef.current = false;
setLoadingMore(false);
setLoadingAll(false);
}
}, [fetchSessionsBatch, continuationRef]);
@@ -523,6 +529,7 @@ export function useDashboardSessions({
loading,
hasMore,
loadingMore,
loadingAll,
refetch,
refetchWith,
loadMore,
@@ -128,7 +128,7 @@ function HomeContent() {
} = useBlockDevice(getAccessToken, addNotification, adminMode, crossTenant);
const {
sessions, loading, hasMore, loadingMore,
sessions, loading, hasMore, loadingMore, loadingAll,
refetch, refetchWith, loadMore, loadAll, removeSession,
} = useDashboardSessions({
user, tenantId, globalAdminMode: crossTenant, joinGlobalAdmins, tenantIdFilter, adminMode,
@@ -478,6 +478,7 @@ function HomeContent() {
onSessionsPerPageChange={handleSessionsPerPageChange}
hasMore={hasMore}
loadingMore={loadingMore}
loadingAll={loadingAll}
onLoadAll={loadAll}
adminMode={adminMode}
globalAdminMode={crossTenant}