From 6bbab8c990dbfc47645f5b778f38c4456394e70b Mon Sep 17 00:00:00 2001 From: krandder Date: Wed, 4 Mar 2026 13:50:10 +0000 Subject: [PATCH] Add position tab indicator dot and auto-switch after trade Show a green dot on the Position tab when the user holds active conditional-token positions. After a successful swap, automatically switch to the Position tab so users see their updated holdings. Closes #17 --- .../marketPage/MarketPageShowcase.jsx | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/components/futarchyFi/marketPage/MarketPageShowcase.jsx b/src/components/futarchyFi/marketPage/MarketPageShowcase.jsx index d85819b..264216e 100644 --- a/src/components/futarchyFi/marketPage/MarketPageShowcase.jsx +++ b/src/components/futarchyFi/marketPage/MarketPageShowcase.jsx @@ -2902,6 +2902,21 @@ const MarketPageShowcase = ({ hidden = false, debugMode = false, proposal = null native: rawBalances.native // Native xDAI balance }), [rawBalances]); + // Detect whether the user holds any active conditional-token position + const hasActivePosition = useMemo(() => { + try { + const currDiff = ethers.utils.parseUnits( + positions?.currencyYes?.total || '0', 18 + ).sub(ethers.utils.parseUnits(positions?.currencyNo?.total || '0', 18)); + const compDiff = ethers.utils.parseUnits( + positions?.companyYes?.total || '0', 18 + ).sub(ethers.utils.parseUnits(positions?.companyNo?.total || '0', 18)); + return !currDiff.isZero() || !compDiff.isZero(); + } catch { + return false; + } + }, [positions]); + // Balance manager handles wallet disconnection automatically const [showEventDetails, setShowEventDetails] = useState(false); @@ -4553,6 +4568,8 @@ const MarketPageShowcase = ({ hidden = false, debugMode = false, proposal = null const handleTransactionComplete = (transactionDetails) => { // Refresh balances or any other state that needs updating refetchBalances(); + // Auto-switch to Position tab so the user sees their updated position + setActiveTab('position'); }; // Add selectedAction state @@ -5282,6 +5299,9 @@ const MarketPageShowcase = ({ hidden = false, debugMode = false, proposal = null }`} > Position + {hasActivePosition && ( + + )} )}