diff --git a/client/src/core/client/admin/routes/Moderate/SiteSelector/SiteSelectorContainer.tsx b/client/src/core/client/admin/routes/Moderate/SiteSelector/SiteSelectorContainer.tsx index fec4e6da9e..c2327f8d02 100644 --- a/client/src/core/client/admin/routes/Moderate/SiteSelector/SiteSelectorContainer.tsx +++ b/client/src/core/client/admin/routes/Moderate/SiteSelector/SiteSelectorContainer.tsx @@ -8,10 +8,12 @@ import { useRefetch, withPaginationContainer, } from "coral-framework/lib/relay"; +import { QueryError } from "coral-ui/components/v3"; import { SiteSelectorContainer_query } from "coral-admin/__generated__/SiteSelectorContainer_query.graphql"; import { SiteSelectorContainer_viewer } from "coral-admin/__generated__/SiteSelectorContainer_viewer.graphql"; import { SiteSelectorContainerPaginationQueryVariables } from "coral-admin/__generated__/SiteSelectorContainerPaginationQuery.graphql"; + import SiteSelector from "./SiteSelector"; interface Props { @@ -31,7 +33,7 @@ const SiteSelectorContainer: React.FunctionComponent = (props) => { const [searchFilter, setSearchFilter] = useState(null); const [searchTimeout, setSearchTimeout] = useState(); - const [, isRefetching] = useRefetch(props.relay, 10, { + const [, isRefetching, refetchError] = useRefetch(props.relay, 10, { searchFilter: searchFilter || null, }); @@ -77,6 +79,10 @@ const SiteSelectorContainer: React.FunctionComponent = (props) => { return { scoped: false, sites: [] }; }, [props.query, props.viewer]); + if (refetchError) { + return ; + } + return ( ( relay: RelayPaginationProp, totalCount: number, variables: Omit -): [RefetchFunction, IsRefetching] { +): [RefetchFunction, IsRefetching, Error | undefined] { const [manualRefetchCount, setManualRefetchCount] = useState(0); const [refetching, setRefetching] = useState(false); + const [err, setErr] = useState(); useEffectWhenChanged(() => { setRefetching(true); const disposable = relay.refetchConnection( @@ -26,6 +27,7 @@ export default function useRefetch( (error) => { setRefetching(false); if (error) { + setErr(error); // eslint-disable-next-line no-console console.error(error); } @@ -45,5 +47,5 @@ export default function useRefetch( return a; }, []), ]); - return [() => setManualRefetchCount(manualRefetchCount + 1), refetching]; + return [() => setManualRefetchCount(manualRefetchCount + 1), refetching, err]; }