Skip to content

Commit

Permalink
Move the preferences to be sent along with the call to launch(), not …
Browse files Browse the repository at this point in the history
…added by the mutation
  • Loading branch information
ianmcorvidae committed Sep 27, 2024
1 parent 6550082 commit 18266a8
Showing 1 changed file with 38 additions and 41 deletions.
79 changes: 38 additions & 41 deletions src/components/instantlaunches/InstantLaunchButtonWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,62 +60,59 @@ function InstantLaunchButtonWrapper(props) {
}
}, [ilUrl]);

const { mutate: launch } = useMutation(
(args) => {
args.preferences = bootstrapInfo?.preferences;
return instantlyLaunch(args);
},
{
onSuccess: (listing) => {
if (listing.analyses.length > 0) {
const analysis = listing.analyses[0];
if (analysis.interactive_urls?.length > 0) {
setIlUrl(
`${
constants.VICE_LOADING_PAGE
}/${encodeURIComponent(
analysis.interactive_urls[0]
)}`
);
} else {
setOpen(false);
}
const { mutate: launch } = useMutation(instantlyLaunch, {
onSuccess: (listing) => {
if (listing.analyses.length > 0) {
const analysis = listing.analyses[0];
if (analysis.interactive_urls?.length > 0) {
setIlUrl(
`${constants.VICE_LOADING_PAGE}/${encodeURIComponent(
analysis.interactive_urls[0]
)}`
);
} else {
setOpen(false);
}
},
onError: (err) => {
} else {
setOpen(false);
}
},
onError: (err) => {
setOpen(false);

const respData = err.response?.data;
const runErrorCode = respData?.error_code;
const details = respData?.details;
const respData = err.response?.data;
const runErrorCode = respData?.error_code;
const details = respData?.details;

if (runErrorCode === ERROR_CODES.ERR_PERMISSION_NEEDED) {
if (details?.pendingRequest) {
setPendingRequestDlgOpen(true);
} else {
setAccessRequestDialogOpen(true);
}
} else if (
runErrorCode === ERROR_CODES.ERR_LIMIT_REACHED ||
runErrorCode === ERROR_CODES.ERR_FORBIDDEN
) {
setRunErrorDetails({ runErrorCode, ...details });
if (runErrorCode === ERROR_CODES.ERR_PERMISSION_NEEDED) {
if (details?.pendingRequest) {
setPendingRequestDlgOpen(true);
} else {
showErrorAnnouncer(err.message, err);
setAccessRequestDialogOpen(true);
}
},
}
);
} else if (
runErrorCode === ERROR_CODES.ERR_LIMIT_REACHED ||
runErrorCode === ERROR_CODES.ERR_FORBIDDEN
) {
setRunErrorDetails({ runErrorCode, ...details });
} else {
showErrorAnnouncer(err.message, err);
}
},
});

const onClick = () => {
if (userProfile?.id) {
if (computeLimitExceeded) {
showErrorAnnouncer(t("computeLimitExceededMsg"));
} else {
setOpen(true);
launch({ instantLaunch, resource, output_dir });
launch({
instantLaunch,
resource,
output_dir,
preferences: bootstrapInfo?.preferences,
});
}
} else {
setSignInDlgOpen(true);
Expand Down

0 comments on commit 18266a8

Please sign in to comment.