Skip to content

Commit

Permalink
feat: [GSW-2033] refetching UI
Browse files Browse the repository at this point in the history
  • Loading branch information
tfrg committed Jan 5, 2025
1 parent 2818333 commit 415b380
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/web/src/hooks/swap/data/use-swap-handler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export const useSwapHandler = () => {
updateSwapAmount,
resetSwapAmount,
isTyping,
isRefetching,
handleResetEstimatedLiquidity,
} = useSwap({
tokenA,
Expand Down Expand Up @@ -1131,6 +1132,7 @@ export const useSwapHandler = () => {
isSwitchNetwork,
switchNetwork,
isLoading: swapState === "LOADING" || isTyping,
isRefetching,
setSwapValue,
tokenA,
tokenB,
Expand Down
2 changes: 2 additions & 0 deletions packages/web/src/hooks/swap/data/use-swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const useSwap = ({ tokenA, tokenB, direction, slippage, swapFee = 15 }: U
const {
data: estimatedSwapResult,
isLoading: isEstimatedSwapLoading,
isRefetching,
error,
} = useGetRoutes(
{
Expand Down Expand Up @@ -309,6 +310,7 @@ export const useSwap = ({ tokenA, tokenB, direction, slippage, swapFee = 15 }: U
updateSwapAmount,
isEstimatedSwapLoading,
isTyping,
isRefetching,
handleResetEstimatedLiquidity,
resetSwapAmount: () => {
setSwapAmount(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface SwapCardProps {
isSwitchNetwork: boolean;
isLoading: boolean;
isSameToken: boolean;
isRefetching: boolean;

changeTokenA: (token: TokenModel) => void;
changeTokenAAmount: (value: string, none?: boolean) => void;
Expand Down Expand Up @@ -76,6 +77,7 @@ const SwapCard: React.FC<SwapCardProps> = ({
setSwapRateAction,
priceImpactStatus,
isSameToken,
isRefetching,
}) => {
const theme = useTheme();
const { t } = useTranslation();
Expand Down Expand Up @@ -109,6 +111,7 @@ const SwapCard: React.FC<SwapCardProps> = ({
isSwitchNetwork={isSwitchNetwork}
priceImpactStatus={priceImpactStatus}
isSameToken={isSameToken}
isRefetching={isRefetching}
resetEstimatedLiquidity={resetEstimatedLiquidity}
/>
{shouldShowPriceImpactWarning && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface ContentProps {
isSwitchNetwork: boolean;
priceImpactStatus: PriceImpactStatus;
isSameToken: boolean;
isRefetching: boolean;
}

const SwapCardContent: React.FC<ContentProps> = ({
Expand All @@ -55,6 +56,7 @@ const SwapCardContent: React.FC<ContentProps> = ({
priceImpactStatus,
isSameToken,
resetEstimatedLiquidity,
isRefetching,
}) => {
const { t } = useTranslation();

Expand Down Expand Up @@ -134,7 +136,11 @@ const SwapCardContent: React.FC<ContentProps> = ({
<div className="amount-container">
<input
id={tokenA?.priceID}
className={`amount-text ${isLoading && direction !== "EXACT_IN" ? "text-opacity" : ""}`}
className={`amount-text ${
(isLoading && direction !== "EXACT_IN") || (isRefetching && direction === "EXACT_OUT")
? "text-opacity"
: ""
}`}
value={tokenAAmount}
onChange={onChangeTokenAAmount}
placeholder="0"
Expand Down Expand Up @@ -171,7 +177,11 @@ const SwapCardContent: React.FC<ContentProps> = ({
<div className="amount-container">
<input
id={tokenB?.priceID}
className={`amount-text ${isLoading && direction === "EXACT_IN" ? "text-opacity" : ""}`}
className={`amount-text ${
(isLoading && direction === "EXACT_IN") || (isRefetching && direction === "EXACT_IN")
? "text-opacity"
: ""
}`}
value={tokenBAmount}
onChange={onChangeTokenBAmount}
placeholder="0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const SwapContainer: React.FC = () => {
isSwitchNetwork,
switchNetwork,
isLoading,
isRefetching,
setSwapValue,
setSwapRateAction,
priceImpactStatus,
Expand Down Expand Up @@ -121,6 +122,7 @@ const SwapContainer: React.FC = () => {
priceImpactStatus={priceImpactStatus}
resetEstimatedLiquidity={handleResetEstimatedLiquidity}
isSameToken={isSameToken}
isRefetching={isRefetching}
/>
);
};
Expand Down

0 comments on commit 415b380

Please sign in to comment.