Skip to content

Commit

Permalink
fix: avoid awaiting then
Browse files Browse the repository at this point in the history
  • Loading branch information
truemiller committed Feb 23, 2024
1 parent aa76ea4 commit ab95854
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions frontend/components/Spawn/SpawnStakingCheck.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,24 +145,20 @@ export const SpawnStakingCheck = ({
message.error(`${userPublicKey} requires more OLAS to stake`);
return setButtonClicked(undefined);
}
const service: Service | undefined = await create(true)
.then((service?: Service) => {
{
message.success('Service created successfully');
return service;
}
})
.catch(() => {
message.error('Failed to create service');
return undefined;
});

if (canStake && service) {
await updateServiceState(service.hash);
setIsStaking(true);
setSpawnScreenState(nextPage);
const service: Service | undefined = await create(true);
if (!service) {
message.error('Failed to create service');
} else {
message.success('Service created successfully');
if (canStake && service) {
await updateServiceState(service.hash).catch(() =>
message.error('Failed to update service state'),
);
setIsStaking(true);
setSpawnScreenState(nextPage);
}
setButtonClicked(undefined);
}
setButtonClicked(undefined);
};

const handleNo = async () => {
Expand Down

0 comments on commit ab95854

Please sign in to comment.