From c8ab797e02246c25b237cb3181e870a90a54929f Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 11 Aug 2020 07:51:55 +0200 Subject: [PATCH] fix run order --- src/components/atoms/Price/index.tsx | 2 +- src/components/organisms/AssetActions/Compute.tsx | 14 +++++++------- src/components/organisms/AssetActions/Consume.tsx | 6 ++++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/components/atoms/Price/index.tsx b/src/components/atoms/Price/index.tsx index 205e04a07..ad4efcd9d 100644 --- a/src/components/atoms/Price/index.tsx +++ b/src/components/atoms/Price/index.tsx @@ -29,7 +29,7 @@ export default function Price({ async function init() { const price = await getBestPrice(ddo.dataToken) setPrice(price) - setPriceOutside && setPriceOutside(price) + setPriceOutside && price !== '' && setPriceOutside(price) } init() }, [chainId]) diff --git a/src/components/organisms/AssetActions/Compute.tsx b/src/components/organisms/AssetActions/Compute.tsx index 289920dbe..cb2c4b449 100644 --- a/src/components/organisms/AssetActions/Compute.tsx +++ b/src/components/organisms/AssetActions/Compute.tsx @@ -33,22 +33,23 @@ export default function Compute({ ddo }: { ddo: DDO }): ReactElement { const [algorithmRawCode, setAlgorithmRawCode] = useState('') const [isPublished, setIsPublished] = useState(false) const [file, setFile] = useState(null) - const [isTermsAgreed, setIsTermsAgreed] = useState(true) const [price, setPrice] = useState() - const isFree = price === '0' - const isComputeButtonDisabled = isJobStarting || file === null || computeType === '' || !ocean || - !isBalanceSufficient || - !isTermsAgreed + !isBalanceSufficient useEffect(() => { if (!price || !balance || !balance.ocean) return - setIsBalanceSufficient(compareAsBN(balance.ocean, price, Comparison.gte)) + + const isFree = price === '0' + + setIsBalanceSufficient( + isFree ? true : compareAsBN(balance.ocean, price, Comparison.gte) + ) return () => { setIsBalanceSufficient(false) @@ -123,7 +124,6 @@ export default function Compute({ ddo }: { ddo: DDO }): ReactElement { Start job - {/* */}