diff --git a/apps/trading/components/navbar/navbar.tsx b/apps/trading/components/navbar/navbar.tsx index c2d0a2bac..57d748361 100644 --- a/apps/trading/components/navbar/navbar.tsx +++ b/apps/trading/components/navbar/navbar.tsx @@ -13,10 +13,11 @@ interface NavbarProps { } export const Navbar = ({ theme, toggleTheme }: NavbarProps) => { - const store = useGlobalStore(); - const tradingPath = store.marketId - ? `/markets/${store.marketId}` - : '/markets'; + const { marketId, update } = useGlobalStore((store) => ({ + marketId: store.marketId, + update: store.update, + })); + const tradingPath = marketId ? `/markets/${marketId}` : '/markets'; return (
@@ -48,9 +49,7 @@ export const Navbar = ({ theme, toggleTheme }: NavbarProps) => { fixedBg="dark" /> { - store.setVegaWalletConnectDialog(open); - }} + setConnectDialog={(open) => update({ connectDialog: open })} />
diff --git a/apps/trading/components/risk-notice-dialog/risk-notice-dialog.spec.tsx b/apps/trading/components/risk-notice-dialog/risk-notice-dialog.spec.tsx index d335afd13..280fa89d7 100644 --- a/apps/trading/components/risk-notice-dialog/risk-notice-dialog.spec.tsx +++ b/apps/trading/components/risk-notice-dialog/risk-notice-dialog.spec.tsx @@ -7,7 +7,7 @@ beforeEach(() => { localStorage.clear(); useGlobalStore.setState((state) => ({ ...state, - vegaRiskNoticeDialog: false, + riskNoticeDialog: false, })); }); diff --git a/apps/trading/components/risk-notice-dialog/risk-notice-dialog.tsx b/apps/trading/components/risk-notice-dialog/risk-notice-dialog.tsx index bcccfab5b..de3acecad 100644 --- a/apps/trading/components/risk-notice-dialog/risk-notice-dialog.tsx +++ b/apps/trading/components/risk-notice-dialog/risk-notice-dialog.tsx @@ -8,28 +8,27 @@ import { useGlobalStore } from '../../stores'; export const RISK_ACCEPTED_KEY = 'vega-risk-accepted'; export const RiskNoticeDialog = () => { - const store = useGlobalStore(); + const { riskNoticeDialog, update } = useGlobalStore((store) => ({ + riskNoticeDialog: store.riskNoticeDialog, + update: store.update, + })); const { VEGA_ENV } = useEnvironment(); useEffect(() => { const isRiskAccepted = LocalStorage.getItem(RISK_ACCEPTED_KEY) === 'true'; if (!isRiskAccepted && VEGA_ENV === Networks.MAINNET) { - store.setVegaRiskNoticeDialog(true); + update({ riskNoticeDialog: true }); } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [store.setVegaRiskNoticeDialog, VEGA_ENV]); + }, [update, VEGA_ENV]); const handleAcceptRisk = () => { - store.setVegaRiskNoticeDialog(false); + update({ riskNoticeDialog: false }); LocalStorage.setItem(RISK_ACCEPTED_KEY, 'true'); }; return ( - +

{t('Regulation may apply to use of this app')}

diff --git a/apps/trading/components/vega-wallet-container/vega-wallet-container.tsx b/apps/trading/components/vega-wallet-container/vega-wallet-container.tsx index 4dd834652..b7be659e7 100644 --- a/apps/trading/components/vega-wallet-container/vega-wallet-container.tsx +++ b/apps/trading/components/vega-wallet-container/vega-wallet-container.tsx @@ -9,7 +9,7 @@ interface VegaWalletContainerProps { } export const VegaWalletContainer = ({ children }: VegaWalletContainerProps) => { - const store = useGlobalStore(); + const { update } = useGlobalStore((store) => ({ update: store.update })); const { keypair } = useVegaWallet(); if (!keypair) { @@ -20,7 +20,7 @@ export const VegaWalletContainer = ({ children }: VegaWalletContainerProps) => { {t('Connect your Vega wallet')}