Skip to content

Commit

Permalink
fix: price no longer resets when closing review modal
Browse files Browse the repository at this point in the history
  • Loading branch information
crnbarr93 committed Aug 13, 2024
1 parent 7bfc00e commit fa33303
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 26 deletions.
5 changes: 2 additions & 3 deletions packages/web/components/place-limit-tool/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import { countDecimals, trimPlaceholderZeros } from "~/utils/number";

export interface PlaceLimitToolProps {
page: EventPage;
refetchOrders: () => Promise<any>;
}

const fixDecimalCount = (value: string, decimalCount = 18) => {
Expand Down Expand Up @@ -80,7 +79,7 @@ const NON_DISPLAY_ERRORS = [
];

export const PlaceLimitTool: FunctionComponent<PlaceLimitToolProps> = observer(
({ page, refetchOrders }: PlaceLimitToolProps) => {
({ page }: PlaceLimitToolProps) => {
const { accountStore } = useStore();
const { t } = useTranslation();
const [reviewOpen, setReviewOpen] = useState<boolean>(false);
Expand Down Expand Up @@ -142,6 +141,7 @@ export const PlaceLimitTool: FunctionComponent<PlaceLimitToolProps> = observer(
type === "market" &&
swapState.priceState.percentAdjusted.abs().gt(new Dec(0))
) {
console.log("RESETTING");
swapState.priceState.reset();
}
}, [swapState.priceState, type]);
Expand Down Expand Up @@ -611,7 +611,6 @@ export const PlaceLimitTool: FunctionComponent<PlaceLimitToolProps> = observer(
confirmAction={async () => {
setIsSendingTx(true);
await swapState.placeLimit();
refetchOrders();
swapState.reset();
setAmountSafe("fiat", "");
setReviewOpen(false);
Expand Down
25 changes: 3 additions & 22 deletions packages/web/components/trade-tool/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from "~/components/swap-tool/swap-tool-tabs";
import { EventName, EventPage } from "~/config";
import { useAmplitudeAnalytics, useTranslation } from "~/hooks";
import { useOrderbookAllActiveOrders } from "~/hooks/limit-orders/use-orderbook";
import { useStore } from "~/stores";

export interface TradeToolProps {
Expand All @@ -37,12 +36,6 @@ export const TradeTool: FunctionComponent<TradeToolProps> = observer(
const { accountStore } = useStore();
const wallet = accountStore.getWallet(accountStore.osmosisChainId);

const { orders, refetch } = useOrderbookAllActiveOrders({
userAddress: wallet?.address ?? "",
pageSize: 10,
refetchInterval: 4000,
});

useEffect(() => {
switch (tab) {
case SwapToolTab.BUY:
Expand Down Expand Up @@ -74,21 +67,9 @@ export const TradeTool: FunctionComponent<TradeToolProps> = observer(
{useMemo(() => {
switch (tab) {
case SwapToolTab.BUY:
return (
<PlaceLimitTool
key="tool-buy"
page={page}
refetchOrders={refetch}
/>
);
return <PlaceLimitTool key="tool-buy" page={page} />;
case SwapToolTab.SELL:
return (
<PlaceLimitTool
key="tool-sell"
page={page}
refetchOrders={refetch}
/>
);
return <PlaceLimitTool key="tool-sell" page={page} />;
case SwapToolTab.SWAP:
default:
return (
Expand All @@ -100,7 +81,7 @@ export const TradeTool: FunctionComponent<TradeToolProps> = observer(
/>
);
}
}, [page, swapToolProps, tab, refetch])}
}, [page, swapToolProps, tab])}
</div>
{wallet?.isWalletConnected && (
<Link
Expand Down
3 changes: 2 additions & 1 deletion packages/web/modals/review-order.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ export function ReviewOrder({
);

useEffect(() => {
if (limitSetPriceLock && orderType === "limit") limitSetPriceLock(isOpen);
if (limitSetPriceLock && orderType === "limit" && isOpen)
limitSetPriceLock(true);
}, [limitSetPriceLock, isOpen, orderType]);

const gasFeeError = useMemo(() => {
Expand Down

0 comments on commit fa33303

Please sign in to comment.