Add wait before updating deployer LRNs after auction completion
This commit is contained in:
parent
e3931b4bf8
commit
e10c8f4818
@ -1080,6 +1080,7 @@ export class Service {
|
||||
if (deployment.isCurrent) {
|
||||
const currentDeploymentURL = `https://${(deployment.project.name).toLowerCase()}.${deployment.baseDomain}`;
|
||||
|
||||
// TODO: Store the latest DNS deployment record
|
||||
const deploymentRecords =
|
||||
await this.laconicRegistry.getDeploymentRecordsByFilter({
|
||||
application: deployment.applicationRecordId,
|
||||
@ -1094,8 +1095,12 @@ export class Service {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Multiple records are fetched, take the latest record
|
||||
const latestRecord = deploymentRecords
|
||||
.sort((a, b) => new Date(b.createTime).getTime() - new Date(a.createTime).getTime())[0];
|
||||
|
||||
await this.laconicRegistry.createApplicationDeploymentRemovalRequest({
|
||||
deploymentId: deploymentRecords[deploymentRecords.length - 1].id,
|
||||
deploymentId: latestRecord.id,
|
||||
deployerLrn: deployment.deployerLrn
|
||||
});
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import { CheckRoundFilledIcon, LoadingIcon } from 'components/shared/CustomIcon'
|
||||
import { useGQLClient } from 'context/GQLClientContext';
|
||||
import { Button, Heading, Tag } from 'components/shared';
|
||||
|
||||
const CHECK_AUCTION_STATUS_INTERVAL = 2000;
|
||||
const WAIT_DURATION = 5000;
|
||||
|
||||
export const AuctionCard = ({ project }: { project: Project }) => {
|
||||
const [auctionStatus, setAuctionStatus] = useState<string>('');
|
||||
@ -28,21 +28,36 @@ export const AuctionCard = ({ project }: { project: Project }) => {
|
||||
const result = await client.getAuctionData(project.auctionId);
|
||||
setAuctionStatus(result.status);
|
||||
setAuctionDetails(result);
|
||||
setDeployerLrns(project.deployerLrns);
|
||||
}, [client, project.auctionId, project.deployerLrns]);
|
||||
}, [client, project.auctionId]);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchUpdatedProject = async () => {
|
||||
if (auctionStatus === 'completed') {
|
||||
// Wait for 5 secs since the project is not immediately updated with deployer LRNs
|
||||
await new Promise((resolve) => setTimeout(resolve, WAIT_DURATION));
|
||||
|
||||
const updatedProject = await client.getProject(project.id);
|
||||
setDeployerLrns(updatedProject.project!.deployerLrns || []);
|
||||
}
|
||||
};
|
||||
|
||||
if (auctionStatus !== 'completed') {
|
||||
const intervalId = setInterval(checkAuctionStatus, CHECK_AUCTION_STATUS_INTERVAL);
|
||||
const intervalId = setInterval(checkAuctionStatus, WAIT_DURATION);
|
||||
checkAuctionStatus();
|
||||
|
||||
return () => clearInterval(intervalId);
|
||||
} else {
|
||||
fetchUpdatedProject();
|
||||
}
|
||||
}, [auctionStatus, checkAuctionStatus]);
|
||||
}, [auctionStatus, checkAuctionStatus, client]);
|
||||
|
||||
const renderAuctionStatus = useCallback(
|
||||
() => (
|
||||
<Tag leftIcon={getIconByAuctionStatus(auctionStatus)} size="xs" type={auctionStatus === 'completed' ? 'positive' : 'emphasized'}>
|
||||
<Tag
|
||||
leftIcon={getIconByAuctionStatus(auctionStatus)}
|
||||
size="xs"
|
||||
type={auctionStatus === 'completed' ? 'positive' : 'emphasized'}
|
||||
>
|
||||
{auctionStatus.toUpperCase()}
|
||||
</Tag>
|
||||
),
|
||||
@ -74,7 +89,7 @@ export const AuctionCard = ({ project }: { project: Project }) => {
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{project.deployerLrns && (
|
||||
{deployerLrns.length > 0 && (
|
||||
<div className="mt-3">
|
||||
<span className="text-elements-high-em text-sm font-medium tracking-tight">Deployer LRNs</span>
|
||||
{deployerLrns.map((lrn, index) => (
|
||||
@ -89,9 +104,7 @@ export const AuctionCard = ({ project }: { project: Project }) => {
|
||||
<Dialog open={openDialog} onClose={handleCloseDialog} fullWidth maxWidth="md">
|
||||
<DialogTitle>Auction Details</DialogTitle>
|
||||
<DialogContent>
|
||||
{auctionDetails && (
|
||||
<pre>{JSON.stringify(auctionDetails, null, 2)}</pre>
|
||||
)}
|
||||
{auctionDetails && <pre>{JSON.stringify(auctionDetails, null, 2)}</pre>}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={handleCloseDialog}>Close</Button>
|
||||
|
Loading…
Reference in New Issue
Block a user