Skip to content

Commit f7b29ec

Browse files
committed
3263 client - Simplify fetch interceptor logic in useFetchInterceptor by removing dynamic import of fetch-intercept
1 parent e7da419 commit f7b29ec

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

client/src/ee/pages/embedded/automation-workflows/workflow-builder/config/useFetchInterceptor.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,17 @@ import {useToast} from '@/hooks/use-toast';
22
import {useWorkspaceStore} from '@/pages/automation/stores/useWorkspaceStore';
33
import {useAuthenticationStore} from '@/shared/stores/useAuthenticationStore';
44
import {useEnvironmentStore} from '@/shared/stores/useEnvironmentStore';
5-
import {useEffect, useState} from 'react';
5+
import fetchIntercept from 'fetch-intercept';
66

77
export default function useFetchInterceptor() {
88
const clearAuthentication = useAuthenticationStore((state) => state.clearAuthentication);
99
const clearCurrentEnvironmentId = useEnvironmentStore((state) => state.clearCurrentEnvironmentId);
1010
const clearCurrentWorkspaceId = useWorkspaceStore((state) => state.clearCurrentWorkspaceId);
11-
const [fetchIntercept, setFetchIntercept] = useState<typeof import('fetch-intercept') | null>(null);
1211

1312
const {toast} = useToast();
1413

1514
const apiBasePath = import.meta.env.VITE_API_BASE_PATH;
1615

17-
useEffect(() => {
18-
import('fetch-intercept').then((module) => setFetchIntercept(module));
19-
}, []);
20-
21-
if (!fetchIntercept) {
22-
return {unregister: () => {}};
23-
}
24-
2516
const unregister = fetchIntercept.register({
2617
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2718
request(url: string, config: any): Promise<any[]> | any[] {

0 commit comments

Comments
 (0)