diff --git a/src/components/organisms/AssetActions/Compute/index.tsx b/src/components/organisms/AssetActions/Compute/index.tsx index 8b6a25639..f09fae7d9 100644 --- a/src/components/organisms/AssetActions/Compute/index.tsx +++ b/src/components/organisms/AssetActions/Compute/index.tsx @@ -359,7 +359,8 @@ export default function Compute({ Logger.log('[compute] Starting compute job response: ', response) - setHasPreviousDatasetOrder(true) + await checkPreviousOrders(selectedAlgorithmAsset) + await checkPreviousOrders(ddo) setIsPublished(true) } catch (error) { setError('Failed to start job!') diff --git a/src/utils/subgraph.ts b/src/utils/subgraph.ts index 1e9fff50f..c38df78a7 100644 --- a/src/utils/subgraph.ts +++ b/src/utils/subgraph.ts @@ -121,11 +121,10 @@ export async function getPreviousOrders( if (assetTimeout === '0') { return fetchedPreviousOrders?.data?.tokenOrders[0]?.tx } else { - const expiry = new BigNumber( - fetchedPreviousOrders?.data?.tokenOrders[0]?.timestamp - ).plus(assetTimeout) - const unixTime = new BigNumber(Math.floor(Date.now() / 1000)) - if (unixTime.isLessThan(expiry)) { + const expiry = + fetchedPreviousOrders?.data?.tokenOrders[0]?.timestamp * 1000 + + Number(assetTimeout) * 1000 + if (Date.now() <= expiry) { return fetchedPreviousOrders?.data?.tokenOrders[0]?.tx } else { return null