This reverts commit 4ce7fc6987, to take
more time to address PR comments
This commit is contained in:
@ -2,11 +2,26 @@ import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { clientConfigApiStatusState } from '@/client-config/states/clientConfigApiStatusState';
|
||||
import { AppFullScreenErrorFallback } from '@/error-handler/components/AppFullScreenErrorFallback';
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import { isMatchingLocation } from '~/utils/isMatchingLocation';
|
||||
|
||||
export const ClientConfigProvider: React.FC<React.PropsWithChildren> = ({
|
||||
children,
|
||||
}) => {
|
||||
const { isErrored, error } = useRecoilValue(clientConfigApiStatusState);
|
||||
const { isLoaded, isErrored, error } = useRecoilValue(
|
||||
clientConfigApiStatusState,
|
||||
);
|
||||
|
||||
const location = useLocation();
|
||||
|
||||
// TODO: Implement a better loading strategy
|
||||
if (
|
||||
!isLoaded &&
|
||||
!isMatchingLocation(location, AppPath.Verify) &&
|
||||
!isMatchingLocation(location, AppPath.VerifyEmail)
|
||||
)
|
||||
return null;
|
||||
|
||||
return isErrored && error instanceof Error ? (
|
||||
<AppFullScreenErrorFallback
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { useClientConfig } from '@/client-config/hooks/useClientConfig';
|
||||
import { apiConfigState } from '@/client-config/states/apiConfigState';
|
||||
import { authProvidersState } from '@/client-config/states/authProvidersState';
|
||||
import { billingState } from '@/client-config/states/billingState';
|
||||
@ -24,6 +23,7 @@ import { domainConfigurationState } from '@/domain-manager/states/domainConfigur
|
||||
import { useEffect } from 'react';
|
||||
import { useRecoilState, useSetRecoilState } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { useGetClientConfigQuery } from '~/generated/graphql';
|
||||
|
||||
export const ClientConfigProviderEffect = () => {
|
||||
const setIsDebugMode = useSetRecoilState(isDebugModeState);
|
||||
@ -87,13 +87,9 @@ export const ClientConfigProviderEffect = () => {
|
||||
isConfigVariablesInDbEnabledState,
|
||||
);
|
||||
|
||||
const { data, loading, error, fetchClientConfig } = useClientConfig();
|
||||
|
||||
useEffect(() => {
|
||||
if (!clientConfigApiStatus.isLoaded) {
|
||||
fetchClientConfig();
|
||||
}
|
||||
}, [clientConfigApiStatus.isLoaded, fetchClientConfig]);
|
||||
const { data, loading, error } = useGetClientConfigQuery({
|
||||
skip: clientConfigApiStatus.isLoaded,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (loading) return;
|
||||
|
||||
Reference in New Issue
Block a user