Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita92853c

Browse files
authored
fix: ensure auto-workspace creation waits until all parameters are ready (#12419)
* fix: ensure auto-workspace creation waits until all parameters are ready* refactor: move creation blocking logic to main callback* fix: let creation start if experimental feature is off
1 parent0fe109d commita92853c

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

‎site/src/pages/CreateWorkspacePage/CreateWorkspacePage.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import{typeFC,useCallback,useEffect,useState}from"react";
1+
import{typeFC,useCallback,useEffect,useState,useRef}from"react";
22
import{Helmet}from"react-helmet-async";
33
import{useMutation,useQuery,useQueryClient}from"react-query";
44
import{useNavigate,useParams,useSearchParams}from"react-router-dom";
@@ -94,19 +94,25 @@ const CreateWorkspacePage: FC = () => {
9494
);
9595

9696
// Auto fill parameters
97+
constautofillEnabled=experiments.includes("auto-fill-parameters");
9798
constuserParametersQuery=useQuery({
9899
queryKey:["userParameters"],
99100
queryFn:()=>getUserParameters(templateQuery.data!.id),
100-
enabled:
101-
experiments.includes("auto-fill-parameters")&&templateQuery.isSuccess,
101+
enabled:autofillEnabled&&templateQuery.isSuccess,
102102
});
103103
constautofillParameters=getAutofillParameters(
104104
searchParams,
105105
userParametersQuery.data ?userParametersQuery.data :[],
106106
);
107107

108+
constautoCreationStartedRef=useRef(false);
108109
constautomateWorkspaceCreation=useEffectEvent(async()=>{
110+
if(autoCreationStartedRef.current){
111+
return;
112+
}
113+
109114
try{
115+
autoCreationStartedRef.current=true;
110116
constnewWorkspace=awaitautoCreateWorkspaceMutation.mutateAsync({
111117
templateName,
112118
organizationId,
@@ -122,11 +128,13 @@ const CreateWorkspacePage: FC = () => {
122128
}
123129
});
124130

131+
constautoStartReady=
132+
mode==="auto"&&(!autofillEnabled||userParametersQuery.isSuccess);
125133
useEffect(()=>{
126-
if(mode==="auto"){
134+
if(autoStartReady){
127135
voidautomateWorkspaceCreation();
128136
}
129-
},[automateWorkspaceCreation,mode]);
137+
},[automateWorkspaceCreation,autoStartReady]);
130138

131139
return(
132140
<>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp