From 04aa033956a1488be7f16d359244b1056898215c Mon Sep 17 00:00:00 2001 From: Piotr Matlak Date: Thu, 11 Apr 2024 15:30:58 +0200 Subject: [PATCH 1/4] remove redirect after disconnecting wallet on position details --- .../SinglePositionWrapper/SinglePositionWrapper.tsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx b/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx index bd72ac2f9..fa90465b3 100644 --- a/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx +++ b/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx @@ -373,12 +373,6 @@ export const SinglePositionWrapper: React.FC = ({ id }) => { ) } - useEffect(() => { - if (!position) { - history.push('/pool') - } - }, [position]) - return !isLoadingList && position ? ( = ({ id }) => { ) : !position ? ( - + ) : null From e2438a3e71f24bd5c582b56a729abf69faeb9c32 Mon Sep 17 00:00:00 2001 From: Piotr Matlak Date: Mon, 15 Apr 2024 11:56:08 +0200 Subject: [PATCH 2/4] refactor redirect to position list from position details --- .../SinglePositionWrapper.tsx | 194 ++++++++++-------- 1 file changed, 114 insertions(+), 80 deletions(-) diff --git a/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx b/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx index fa90465b3..f085fab8b 100644 --- a/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx +++ b/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx @@ -32,6 +32,7 @@ import React, { useEffect, useMemo, useState } from 'react' import { useDispatch, useSelector } from 'react-redux' import { useHistory } from 'react-router' import useStyles from './style' +import { Redirect } from 'react-router-dom' export interface IProps { id: string @@ -67,6 +68,8 @@ export const SinglePositionWrapper: React.FC = ({ id }) => { const [showFeesLoader, setShowFeesLoader] = useState(true) + const [isFinishedDelayRender, setIsFinishedDelayRender] = useState(false) + useEffect(() => { if (position?.id && waitingForTicksData === null) { setWaitingForTicksData(true) @@ -373,87 +376,118 @@ export const SinglePositionWrapper: React.FC = ({ id }) => { ) } - return !isLoadingList && position ? ( - { - dispatch(actions.claimFee(position.positionIndex)) - }} - closePosition={claimFarmRewards => { - dispatch( - actions.closePosition({ - positionIndex: position.positionIndex, - onSuccess: () => { - history.push('/pool') - }, - claimFarmRewards - }) - ) - }} - ticksLoading={ticksLoading} - tickSpacing={position?.poolData.tickSpacing ?? 1} - tokenX={{ - name: position.tokenX.symbol, - icon: position.tokenX.logoURI, - decimal: position.tokenX.decimals, - balance: +printBN(position.tokenX.balance, position.tokenX.decimals), - liqValue: tokenXLiquidity, - claimValue: tokenXClaim, - usdValue: - typeof tokenXPriceData?.price === 'undefined' - ? undefined - : tokenXPriceData.price * +printBN(position.tokenX.balance, position.tokenX.decimals) - }} - tokenXPriceData={tokenXPriceData} - tokenY={{ - name: position.tokenY.symbol, - icon: position.tokenY.logoURI, - decimal: position.tokenY.decimals, - balance: +printBN(position.tokenY.balance, position.tokenY.decimals), - liqValue: tokenYLiquidity, - claimValue: tokenYClaim, - usdValue: - typeof tokenYPriceData?.price === 'undefined' - ? undefined - : tokenYPriceData.price * +printBN(position.tokenY.balance, position.tokenY.decimals) - }} - tokenYPriceData={tokenYPriceData} - fee={position.poolData.fee} - min={min} - max={max} - initialIsDiscreteValue={initialIsDiscreteValue} - onDiscreteChange={setIsDiscreteValue} - showFeesLoader={showFeesLoader} - hasTicksError={hasTicksError} - reloadHandler={() => { - dispatch( - actions.getCurrentPlotTicks({ - poolIndex: position.poolData.poolIndex, - isXtoY: true - }) - ) - }} - plotVolumeRange={currentVolumeRange} - userHasStakes={!!positionStakes.length} - globalPrice={globalPrice} - xToY={xToY} - setXToY={setXToY} - /> - ) : isLoadingList ? ( - - - - ) : !position ? ( + useEffect(() => { + const timer = setTimeout(() => { + setIsFinishedDelayRender(true) + }, 1000) + + return () => { + clearTimeout(timer) + } + }, [walletStatus]) + + useEffect(() => { + if (isFinishedDelayRender) { + setIsFinishedDelayRender(false) + } + }, [walletStatus]) + + if (!isLoadingList && position) { + return ( + { + dispatch(actions.claimFee(position.positionIndex)) + }} + closePosition={claimFarmRewards => { + dispatch( + actions.closePosition({ + positionIndex: position.positionIndex, + onSuccess: () => { + history.push('/pool') + }, + claimFarmRewards + }) + ) + }} + ticksLoading={ticksLoading} + tickSpacing={position?.poolData.tickSpacing ?? 1} + tokenX={{ + name: position.tokenX.symbol, + icon: position.tokenX.logoURI, + decimal: position.tokenX.decimals, + balance: +printBN(position.tokenX.balance, position.tokenX.decimals), + liqValue: tokenXLiquidity, + claimValue: tokenXClaim, + usdValue: + typeof tokenXPriceData?.price === 'undefined' + ? undefined + : tokenXPriceData.price * +printBN(position.tokenX.balance, position.tokenX.decimals) + }} + tokenXPriceData={tokenXPriceData} + tokenY={{ + name: position.tokenY.symbol, + icon: position.tokenY.logoURI, + decimal: position.tokenY.decimals, + balance: +printBN(position.tokenY.balance, position.tokenY.decimals), + liqValue: tokenYLiquidity, + claimValue: tokenYClaim, + usdValue: + typeof tokenYPriceData?.price === 'undefined' + ? undefined + : tokenYPriceData.price * +printBN(position.tokenY.balance, position.tokenY.decimals) + }} + tokenYPriceData={tokenYPriceData} + fee={position.poolData.fee} + min={min} + max={max} + initialIsDiscreteValue={initialIsDiscreteValue} + onDiscreteChange={setIsDiscreteValue} + showFeesLoader={showFeesLoader} + hasTicksError={hasTicksError} + reloadHandler={() => { + dispatch( + actions.getCurrentPlotTicks({ + poolIndex: position.poolData.poolIndex, + isXtoY: true + }) + ) + }} + plotVolumeRange={currentVolumeRange} + userHasStakes={!!positionStakes.length} + globalPrice={globalPrice} + xToY={xToY} + setXToY={setXToY} + /> + ) + } + + if ( + isLoadingList || + (!position && walletStatus === Status.Uninitialized && !isFinishedDelayRender) + ) { + return ( + + + + ) + } + + if (!position && walletStatus === Status.Initialized && isFinishedDelayRender) { + return + } + + return ( - ) : null + ) } From c1c1df6048e53e79ad2a2dec098a09a92a5e71ff Mon Sep 17 00:00:00 2001 From: Piotr Matlak Date: Tue, 16 Apr 2024 11:13:03 +0200 Subject: [PATCH 3/4] fix center interface and loader on position details page --- .../SinglePositionWrapper.tsx | 14 +++++++++++--- src/containers/SinglePositionWrapper/style.ts | 3 +++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx b/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx index 807435628..e15a55e35 100644 --- a/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx +++ b/src/containers/SinglePositionWrapper/SinglePositionWrapper.tsx @@ -474,11 +474,15 @@ export const SinglePositionWrapper: React.FC = ({ id }) => { } if ( - isLoadingList || + (isLoadingList && walletStatus === Status.Initialized) || (!position && walletStatus === Status.Uninitialized && !isFinishedDelayRender) ) { return ( - + ) @@ -489,7 +493,11 @@ export const SinglePositionWrapper: React.FC = ({ id }) => { } return ( - + ) diff --git a/src/containers/SinglePositionWrapper/style.ts b/src/containers/SinglePositionWrapper/style.ts index b8c6f78f9..5878e231e 100644 --- a/src/containers/SinglePositionWrapper/style.ts +++ b/src/containers/SinglePositionWrapper/style.ts @@ -11,6 +11,9 @@ const useStyles = makeStyles(() => ({ width: 150, height: 150, margin: 'auto' + }, + fullHeightContainer: { + height: '100%' } })) From 4e9a50fc0e08cb56d9a71a23848baaf2f486ad61 Mon Sep 17 00:00:00 2001 From: Piotr Matlak Date: Tue, 16 Apr 2024 11:23:03 +0200 Subject: [PATCH 4/4] update @nightlylabs/wallet-selector-solana to 0.3.1 version --- package-lock.json | 30 +++++++++++++++--------------- package.json | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index ac552f388..b8d6e208e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@material-ui/icons": "^4.9.1", "@material-ui/lab": "^4.0.0-alpha.56", "@mdx-js/react": "^1.6.22", - "@nightlylabs/wallet-selector-solana": "0.2.7", + "@nightlylabs/wallet-selector-solana": "^0.3.1", "@nivo/bar": "^0.73.1", "@nivo/core": "^0.73.0", "@nivo/line": "^0.73.0", @@ -3717,9 +3717,9 @@ "peer": true }, "node_modules/@lit-labs/ssr-dom-shim": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.1.2.tgz", - "integrity": "sha512-jnOD+/+dSrfTWYfSXBXlo5l5f0q1UuJo3tkbMDCYA2lKUYq79jaxqtGEvnRoh049nt1vdo1+45RinipU6FGY2g==" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.2.0.tgz", + "integrity": "sha512-yWJKmpGE6lUURKAaIltoPIE/wrbY3TEkqQt+X0m+7fQNnAv0keydnYvbiJFP1PnMhizmIWRWOG5KLhYyc/xl+g==" }, "node_modules/@lit/reactive-element": { "version": "1.6.3", @@ -4182,20 +4182,20 @@ } }, "node_modules/@nightlylabs/wallet-selector-base": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/@nightlylabs/wallet-selector-base/-/wallet-selector-base-0.2.5.tgz", - "integrity": "sha512-VXvgXEfHuOVDIhnAkO5wh1Z2BoIJogSYpSrVddjf8klmL+lPXw29wC60esn++J9ia+Lt/TvJ/NvUDsML4sirsw==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@nightlylabs/wallet-selector-base/-/wallet-selector-base-0.4.0.tgz", + "integrity": "sha512-NCreMsiNzd5Rvu76cNTwtrCrB5iCBV+NtPZbhyUWfagbxROS1AJsZuIt+Af+AVjHFDS/7MQS37SJi1EX6XCp8Q==", "dependencies": { "@nightlylabs/nightly-connect-base": "0.0.27", - "@nightlylabs/wallet-selector-modal": "0.1.2", + "@nightlylabs/wallet-selector-modal": "0.2.1", "@wallet-standard/core": "^1.0.3", "isomorphic-localstorage": "^1.0.2" } }, "node_modules/@nightlylabs/wallet-selector-modal": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/@nightlylabs/wallet-selector-modal/-/wallet-selector-modal-0.1.2.tgz", - "integrity": "sha512-vxy9S2dEf3NARW6LDq2ZKpWMlk5JJFIuwUfSxkuJlgUg2OVSlnDS7vdho3h4DmluRU5GM9vVhaXUGHAVp5sDQg==", + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@nightlylabs/wallet-selector-modal/-/wallet-selector-modal-0.2.1.tgz", + "integrity": "sha512-jJghrmUtKwHiSaH0c4Tc8befpqGP23AjTFsQ/Eucpa7uz90lFZ9FHmw+bZZKabqYgI0j+uyViiyfwaPcVPKjlQ==", "dependencies": { "@nightlylabs/qr-code": "2.0.4", "autoprefixer": "^10.4.14", @@ -4206,12 +4206,12 @@ } }, "node_modules/@nightlylabs/wallet-selector-solana": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/@nightlylabs/wallet-selector-solana/-/wallet-selector-solana-0.2.7.tgz", - "integrity": "sha512-+V2Na1MlKSNPQXkvwe0IszsLPu1evlyOYxSiLatSwTeQSh2CKpB0bWHVT7ucnKes6gvA/1T9g6nE5CRJwqThAA==", + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@nightlylabs/wallet-selector-solana/-/wallet-selector-solana-0.3.1.tgz", + "integrity": "sha512-M6oq8us+7R72dh+YJEc8fDvmwfceUn5grpU7KHJVx5PNAGqsZLBER4mMAXF1TDRfwzy1ielp+6wehaCj6rOhAg==", "dependencies": { "@nightlylabs/nightly-connect-solana": "^0.0.29", - "@nightlylabs/wallet-selector-base": "^0.2.4", + "@nightlylabs/wallet-selector-base": "^0.4.0", "@solana/wallet-adapter-base": "^0.9.22", "@solana/wallet-standard": "^1.0.2", "@solana/web3.js": "^1.77.2", diff --git a/package.json b/package.json index c257b4ea4..9e54fbf05 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@material-ui/icons": "^4.9.1", "@material-ui/lab": "^4.0.0-alpha.56", "@mdx-js/react": "^1.6.22", - "@nightlylabs/wallet-selector-solana": "0.2.7", + "@nightlylabs/wallet-selector-solana": "^0.3.1", "@nivo/bar": "^0.73.1", "@nivo/core": "^0.73.0", "@nivo/line": "^0.73.0",