fix(shareModal/index.tsx): add conditional check for hasApiKey before calling handleGetTags and handleGetNames to prevent unnecessary API calls when there is no API key available
This commit is contained in:
parent
b60fd7f04d
commit
61ad880990
1 changed files with 7 additions and 3 deletions
|
|
@ -15,6 +15,7 @@ import { FlowType } from "../../types/flow";
|
||||||
import { removeApiKeys } from "../../utils/reactflowUtils";
|
import { removeApiKeys } from "../../utils/reactflowUtils";
|
||||||
import { getTagsIds } from "../../utils/storeUtils";
|
import { getTagsIds } from "../../utils/storeUtils";
|
||||||
import BaseModal from "../baseModal";
|
import BaseModal from "../baseModal";
|
||||||
|
import { StoreContext } from "../../contexts/storeContext";
|
||||||
|
|
||||||
export default function ShareModal({
|
export default function ShareModal({
|
||||||
component,
|
component,
|
||||||
|
|
@ -30,6 +31,7 @@ export default function ShareModal({
|
||||||
setOpen?: (open: boolean) => void;
|
setOpen?: (open: boolean) => void;
|
||||||
}): JSX.Element {
|
}): JSX.Element {
|
||||||
const { version, addFlow } = useContext(FlowsContext);
|
const { version, addFlow } = useContext(FlowsContext);
|
||||||
|
const {hasApiKey} = useContext(StoreContext)
|
||||||
const { setSuccessData, setErrorData } = useContext(alertContext);
|
const { setSuccessData, setErrorData } = useContext(alertContext);
|
||||||
const [checked, setChecked] = useState(true);
|
const [checked, setChecked] = useState(true);
|
||||||
const [name, setName] = useState(component?.name ?? "");
|
const [name, setName] = useState(component?.name ?? "");
|
||||||
|
|
@ -46,10 +48,12 @@ export default function ShareModal({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (open || internalOpen) {
|
if (open || internalOpen) {
|
||||||
handleGetTags();
|
if(hasApiKey){
|
||||||
handleGetNames();
|
handleGetTags();
|
||||||
|
handleGetNames();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [open, internalOpen]);
|
}, [open, internalOpen,hasApiKey]);
|
||||||
|
|
||||||
function handleGetTags() {
|
function handleGetTags() {
|
||||||
setLoadingTags(true);
|
setLoadingTags(true);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue