diff --git a/src/components/AddContentModal/index.tsx b/src/components/AddContentModal/index.tsx index a56230997..738aca397 100644 --- a/src/components/AddContentModal/index.tsx +++ b/src/components/AddContentModal/index.tsx @@ -113,6 +113,8 @@ const handleSubmitForm = async ( Authorization: lsatToken, }) + await updateBudget(setBudget) + if (res.data.project_id) { setRunningProjectId(res.data.project_id) } @@ -127,7 +129,7 @@ const handleSubmitForm = async ( } catch (err: any) { if (err.status === 402) { await payLsat(setBudget) - await updateBudget(setBudget) + await handleSubmitForm(data, sourceType, setBudget, setRunningProjectId) } else { let errorMessage = NODE_ADD_ERROR diff --git a/src/components/Auth/index.tsx b/src/components/Auth/index.tsx index 98f9b3fbf..ec733a357 100644 --- a/src/components/Auth/index.tsx +++ b/src/components/Auth/index.tsx @@ -55,12 +55,10 @@ export const AuthGuard = ({ children }: PropsWithChildren) => { setPubKey('') } - await updateBudget(setBudget) - if (isE2E || isDevelopment) { setIsAuthenticated(true) } - }, [setBudget, setPubKey, setIsAuthenticated]) + }, [setPubKey, setIsAuthenticated]) const handleIsAdmin = useCallback(async () => { try { @@ -116,11 +114,13 @@ export const AuthGuard = ({ children }: PropsWithChildren) => { } } + await updateBudget(setBudget) + await handleIsAdmin() } init() - }, [handleAuth, handleIsAdmin]) + }, [handleAuth, handleIsAdmin, setBudget]) const message = 'This is a private Graph, Contact Admin' diff --git a/src/network/fetchGraphData/index.ts b/src/network/fetchGraphData/index.ts index d87d1c7a2..f9c763384 100644 --- a/src/network/fetchGraphData/index.ts +++ b/src/network/fetchGraphData/index.ts @@ -1,7 +1,7 @@ import { isDevelopment, isE2E } from '~/constants' import { api } from '~/network/api' import { FetchDataResponse } from '~/types' -import { payLsat } from '~/utils' +import { payLsat, updateBudget } from '~/utils' import { getLSat } from '~/utils/getLSat' // Main function to fetch graph data @@ -30,6 +30,8 @@ const fetchNodes = async ( try { const response = await api.get(url, { Authorization: lsatToken }, signal) + updateBudget(setBudget) + return response // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (error: any) {