forked from langflow-ai/langflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: refactor get all to fix types not being fetched before checking …
…for outdated components (langflow-ai#4762) * Added use get types to fetch types from backend using tanstack * Updated typesStore to use new set types * Updated project to not use getTypes anymore * deleted unused getTypes * add tests * [autofix.ci] apply automated fixes * fix tests --------- Co-authored-by: cristhianzl <cristhian.lousa@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
- Loading branch information
1 parent
1ebbd84
commit 75fd0ce
Showing
13 changed files
with
1,203 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/frontend/src/controllers/API/queries/flows/use-get-types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import useFlowsManagerStore from "@/stores/flowsManagerStore"; | ||
import { useTypesStore } from "@/stores/typesStore"; | ||
import { APIObjectType, useQueryFunctionType } from "../../../../types/api"; | ||
import { api } from "../../api"; | ||
import { getURL } from "../../helpers/constants"; | ||
import { UseRequestProcessor } from "../../services/request-processor"; | ||
|
||
export const useGetTypes: useQueryFunctionType<undefined> = (options) => { | ||
const { query } = UseRequestProcessor(); | ||
const setLoading = useFlowsManagerStore((state) => state.setIsLoading); | ||
const setTypes = useTypesStore((state) => state.setTypes); | ||
|
||
const getTypesFn = async () => { | ||
try { | ||
const response = await api.get<APIObjectType>( | ||
`${getURL("ALL")}?force_refresh=true`, | ||
); | ||
const data = response?.data; | ||
setTypes(data); | ||
return data; | ||
} catch { | ||
(error) => { | ||
console.error("An error has occurred while fetching types."); | ||
console.log(error); | ||
setLoading(false); | ||
throw error; | ||
}; | ||
} | ||
}; | ||
|
||
const queryResult = query(["useGetTypes"], getTypesFn, { | ||
refetchOnWindowFocus: false, | ||
...options, | ||
}); | ||
|
||
return queryResult; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.