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 { getTagsIds } from "../../utils/storeUtils";
|
||||
import BaseModal from "../baseModal";
|
||||
import { StoreContext } from "../../contexts/storeContext";
|
||||
|
||||
export default function ShareModal({
|
||||
component,
|
||||
|
|
@ -30,6 +31,7 @@ export default function ShareModal({
|
|||
setOpen?: (open: boolean) => void;
|
||||
}): JSX.Element {
|
||||
const { version, addFlow } = useContext(FlowsContext);
|
||||
const {hasApiKey} = useContext(StoreContext)
|
||||
const { setSuccessData, setErrorData } = useContext(alertContext);
|
||||
const [checked, setChecked] = useState(true);
|
||||
const [name, setName] = useState(component?.name ?? "");
|
||||
|
|
@ -46,10 +48,12 @@ export default function ShareModal({
|
|||
|
||||
useEffect(() => {
|
||||
if (open || internalOpen) {
|
||||
handleGetTags();
|
||||
handleGetNames();
|
||||
if(hasApiKey){
|
||||
handleGetTags();
|
||||
handleGetNames();
|
||||
}
|
||||
}
|
||||
}, [open, internalOpen]);
|
||||
}, [open, internalOpen,hasApiKey]);
|
||||
|
||||
function handleGetTags() {
|
||||
setLoadingTags(true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue