From 99334f4d743a757bff23886293a67716b2c9e448 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 26 Oct 2020 18:13:12 +0100 Subject: [PATCH] refactor pool data flow --- .../organisms/AssetActions/Pool/index.tsx | 23 +++++++------------ src/utils/checkPreviousOrder.ts | 2 ++ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/components/organisms/AssetActions/Pool/index.tsx b/src/components/organisms/AssetActions/Pool/index.tsx index 5e59b49f6..dada2f442 100644 --- a/src/components/organisms/AssetActions/Pool/index.tsx +++ b/src/components/organisms/AssetActions/Pool/index.tsx @@ -54,7 +54,6 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement { const [showAdd, setShowAdd] = useState(false) const [showRemove, setShowRemove] = useState(false) - const [isLoading, setIsLoading] = useState(true) // TODO: put all these variables behind some useEffect // to prevent unneccessary updating on every render @@ -76,8 +75,6 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement { if (!ocean || !accountId || !price || !price.value) return async function init() { - setIsLoading(true) - try { // // Get everything which is in the pool @@ -116,8 +113,6 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement { setSwapFee(`${Number(swapFee) * 100}`) } catch (error) { Logger.error(error.message) - } finally { - setIsLoading(false) } } init() @@ -125,9 +120,7 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement { return ( <> - {isLoading && !userLiquidity ? ( - - ) : showAdd ? ( + {showAdd ? (
={' '} - - + +
Pool @@ -174,8 +167,8 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement { } - ocean={`${userLiquidity.ocean}`} - dt={`${userLiquidity.datatoken}`} + ocean={`${userLiquidity?.ocean}` || '0'} + dt={`${userLiquidity?.datatoken}` || '0'} dtSymbol={dtSymbol} poolShares={poolTokens} conversion={totalUserLiquidityInOcean} @@ -186,8 +179,8 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {