From d3cd7601547bb7e2f87466ed28ee5dc4142bf020 Mon Sep 17 00:00:00 2001 From: Dima Grossman Date: Mon, 1 Jul 2024 23:05:01 +0300 Subject: [PATCH] feat(web): fix cloud bridge status (#5904) * feat: fix cloud bridge status * fix: bridge api --- apps/web/src/studio/hooks/useBridgeAPI.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/web/src/studio/hooks/useBridgeAPI.ts b/apps/web/src/studio/hooks/useBridgeAPI.ts index 6f002c2e84e..ce1122f50d5 100644 --- a/apps/web/src/studio/hooks/useBridgeAPI.ts +++ b/apps/web/src/studio/hooks/useBridgeAPI.ts @@ -7,6 +7,7 @@ import { type BridgeStatus, } from '../../bridgeApi/bridgeApi.client'; import { useStudioState } from '../StudioStateProvider'; +import { api as cloudApi } from '../../api'; function useBridgeAPI() { const { bridgeURL } = useStudioState(); @@ -14,7 +15,7 @@ function useBridgeAPI() { return useMemo(() => buildBridgeHTTPClient(bridgeURL), [bridgeURL]); } -const BRIDGE_STATUS_REFRESH_INTERVAL_IN_MS = 3 * 1000; +const BRIDGE_STATUS_REFRESH_INTERVAL_IN_MS = 5 * 1000; export const useDiscover = (options?: any) => { const api = useBridgeAPI(); @@ -29,14 +30,18 @@ export const useDiscover = (options?: any) => { }; export const useHealthCheck = (options?: any) => { - const api = useBridgeAPI(); - const { bridgeURL } = useStudioState(); + const bridgeAPI = useBridgeAPI(); + const { bridgeURL, isLocalStudio } = useStudioState(); const res = useQuery( ['bridge-health-check', bridgeURL], async () => { try { - return await api.healthCheck(); + if (isLocalStudio) { + return await bridgeAPI.healthCheck(); + } else { + return await cloudApi.get('/v1/bridge/status'); + } } catch (error) { throw error; }