Skip to content

Commit 55f3f63

Browse files
committed
fix: solved main loading issues
Signed-off-by: Alejandro Parcet <[email protected]>
1 parent 44004a0 commit 55f3f63

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

node/src/components/data/JobSelector.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,12 @@ export default function JobsSelector(props: JobSelectorPropsType) {
279279
updateJobContext(newJobCollections);
280280
}, [jobCollections, updateJobContext]);
281281

282+
const handleJobsUpdate = useCallback(async () => {
283+
setJobCollections([]);
284+
await updateJobCollections(selectedFunction?.uid as string);
285+
console.info("Updated JobCollections");
286+
}, [selectedFunction, updateJobCollections]);
287+
282288
useEffect(() => {
283289
if (jobCollections.length > 0 && loading === true) {
284290
onToggleAll(true);
@@ -288,23 +294,15 @@ export default function JobsSelector(props: JobSelectorPropsType) {
288294
}, [jobCollections, loading, onToggleAll, setIsSuMoGenerated, setLoading, updateJobContext]);
289295

290296
useEffect(() => {
291-
console.info("useEffect in JobsSelector triggered");
292-
if (selectedFunction === undefined || jobCollections.length === 0) {
297+
console.info("useEffect in JobsSelector triggered", selectedFunction, jobCollections);
298+
if (selectedFunction === undefined || jobCollections.length > 0) {
293299
return;
294300
}
295301
console.info("Function selected: ", selectedFunction.uid);
296-
(async () => {
297-
setJobCollections([]);
298-
await updateJobCollections(selectedFunction?.uid as string);
299-
console.info("Updated JobCollections");
300-
})();
302+
handleJobsUpdate();
301303

302304
console.info("Function selected: ", selectedFunction.uid);
303-
(async () => {
304-
setJobCollections([]);
305-
await updateJobCollections(selectedFunction?.uid as string);
306-
console.info("Updated JobCollections");
307-
})();
305+
handleJobsUpdate();
308306
// eslint-disable-next-line react-hooks/exhaustive-deps
309307
}, [selectedFunction]);
310308

0 commit comments

Comments
 (0)