Skip to content

Commit

Permalink
fix(deployment): only set the template and redirect once when loading…
Browse files Browse the repository at this point in the history
… new deployment
  • Loading branch information
baktun14 committed Sep 30, 2024
1 parent b39b057 commit 4db8eaf
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const NewDeploymentContainer: FC = () => {
const [activeStep, setActiveStep] = useState<number | null>(null);
const [selectedTemplate, setSelectedTemplate] = useState<TemplateCreation | null>(null);
const [editedManifest, setEditedManifest] = useState<string | null>(null);
const [isInit, setIsInit] = useState(false);
const deploySdl = useAtomValue(sdlStore.deploySdl);
const { getDeploymentData } = useLocalNotes();
const { getTemplateById } = useTemplates();
Expand All @@ -37,7 +38,7 @@ export const NewDeploymentContainer: FC = () => {
}, [searchParams]);

useEffect(() => {
if (!templates || editedManifest) return;
if (!templates || editedManifest || isInit) return;

const template = getRedeployTemplate() || getGalleryTemplate();

Expand All @@ -53,8 +54,11 @@ export const NewDeploymentContainer: FC = () => {
if (queryStep !== RouteStep.editDeployment) {
router.replace(UrlService.newDeployment({ ...searchParams, step: RouteStep.editDeployment }));
}

setIsInit(true);
}
}, [templates, editedManifest, searchParams, router, toggleCmp, hasComponent]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [templates, editedManifest, searchParams, router, toggleCmp, hasComponent, isInit]);

const getRedeployTemplate = () => {
let template: Partial<TemplateCreation> | null = null;
Expand Down

0 comments on commit 4db8eaf

Please sign in to comment.