diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index 8b5e554a..3fd91bd9 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -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 }); } diff --git a/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx b/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx index 24d57c38..2ef7f5e3 100644 --- a/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx +++ b/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx @@ -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(''); @@ -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( () => ( - + {auctionStatus.toUpperCase()} ), @@ -54,49 +69,47 @@ export const AuctionCard = ({ project }: { project: Project }) => { return ( <> -
-
- Auction details - -
- -
- Auction Status -
{renderAuctionStatus()}
-
- -
- Auction Id - - {project.auctionId} - -
- - {project.deployerLrns && ( -
- Deployer LRNs - {deployerLrns.map((lrn, index) => ( -

- {'\u2022'} {lrn} -

- ))} +
+
+ Auction details +
- )} -
- - Auction Details - - {auctionDetails && ( -
{JSON.stringify(auctionDetails, null, 2)}
+
+ Auction Status +
{renderAuctionStatus()}
+
+ +
+ Auction Id + + {project.auctionId} + +
+ + {deployerLrns.length > 0 && ( +
+ Deployer LRNs + {deployerLrns.map((lrn, index) => ( +

+ {'\u2022'} {lrn} +

+ ))} +
)} -
- - - -
- +
+ + + Auction Details + + {auctionDetails &&
{JSON.stringify(auctionDetails, null, 2)}
} +
+ + + +
+ ); };