Files
silo-server/web/src/hooks/useCanRequest.ts
T
Silo Server Migration 77c8309a4c commit message
{"subject":"fix(search): prevent empty-state flash before TMDB fallback renders","body":"- Add isResolving to useCanRequest and gate empty states on it across GlobalSearch and Catalog\n- Debounce TMDB query in Catalog and hide ItemGrid when the request section may rescue an empty library\n- Track per-card submit state in RequestToAddSection grid so concurrent requests don't trample each other\n- Suppress anonymous TMDB request-search fetches to avoid cross-viewer cache leakage"}
2026-05-25 22:27:46 -04:00

27 lines
848 B
TypeScript

import { useRequestFeatureStatus } from "@/hooks/queries/useRequests";
import { useCurrentProfile } from "@/hooks/useCurrentProfile";
export interface CanRequestState {
discoveryEnabled: boolean;
/**
* True while we cannot yet decide if discovery is on — feature status
* is still loading. Consumers should suppress empty-state UI in this
* window to avoid a flash before the request section appears.
*/
isResolving: boolean;
submitDisabledReason: string | null;
}
export function useCanRequest(): CanRequestState {
const status = useRequestFeatureStatus();
const { profile } = useCurrentProfile();
const discoveryEnabled = Boolean(status.data?.requests_enabled) && Boolean(profile?.id);
const isResolving = status.isLoading;
return {
discoveryEnabled,
isResolving,
submitDisabledReason: null,
};
}