Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 411925a

Browse files
committed
fix: check for classic flowremove localstorage set on queryFn
1 parent cf98268 commit 411925a

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

site/src/pages/CreateWorkspacePage/CreateWorkspaceExperimentRouter.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,26 @@ const CreateWorkspaceExperimentRouter: FC = () => {
3030
templateQuery.data.id,
3131
"optOut",
3232
],
33-
queryFn: () => ({
34-
templateId: templateQuery.data.id,
35-
optedOut:
36-
localStorage.getItem(optOutKey(templateQuery.data.id)) === "true",
37-
}),
33+
queryFn: () => {
34+
const templateId = templateQuery.data.id;
35+
const localStorageKey = optOutKey(templateId);
36+
const storedOptOutString = localStorage.getItem(localStorageKey);
37+
38+
let optOutResult: boolean;
39+
40+
if (storedOptOutString !== null) {
41+
optOutResult = storedOptOutString === "true";
42+
} else {
43+
optOutResult = Boolean(
44+
templateQuery.data.use_classic_parameter_flow,
45+
);
46+
}
47+
48+
return {
49+
templateId: templateId,
50+
optedOut: optOutResult,
51+
};
52+
},
3853
}
3954
: { enabled: false },
4055
);

0 commit comments

Comments
 (0)