diff --git a/.husky/pre-commit b/.husky/pre-commit index 6a63f852..73bbdf5c 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -yarn format && yarn typecheck && yarn lint --quiet +yarn typecheck && yarn lint --quiet && yarn format diff --git a/components/MangoProvider.tsx b/components/MangoProvider.tsx index 59a19fcb..23e8bd9f 100644 --- a/components/MangoProvider.tsx +++ b/components/MangoProvider.tsx @@ -53,26 +53,16 @@ const HydrateStore = () => { // watch selected Mango Account for changes useEffect(() => { const client = mangoStore.getState().client - if (!mangoAccountPk) return - const subscriptionId = connection.onAccountChange( mangoAccountPk, async (info, context) => { if (info?.lamports === 0) return const lastSeenSlot = mangoStore.getState().mangoAccount.lastSlot - // const mangoAccountLastUpdated = new Date( - // mangoStore.getState().mangoAccount.lastUpdatedAt - // ) const mangoAccount = mangoStore.getState().mangoAccount.current if (!mangoAccount) return - // const newUpdatedAt = new Date() - // const timeDiff = - // mangoAccountLastUpdated.getTime() - newUpdatedAt.getTime() - // only updated mango account if it's been more than 1 second since last update - // if (Math.abs(timeDiff) >= 500 && context.slot > lastSeenSlot) { if (context.slot > lastSeenSlot) { const decodedMangoAccount = client.program.coder.accounts.decode( 'mangoAccount', @@ -83,10 +73,8 @@ const HydrateStore = () => { decodedMangoAccount ) await newMangoAccount.reloadSerum3OpenOrders(client) - actions.fetchOpenOrders() - // newMangoAccount.spotOpenOrdersAccounts = - // mangoAccount.spotOpenOrdersAccounts - // newMangoAccount.advancedOrders = mangoAccount.advancedOrders + actions.fetchOpenOrders(newMangoAccount) + set((s) => { s.mangoAccount.current = newMangoAccount s.mangoAccount.lastSlot = context.slot diff --git a/components/TokenList.tsx b/components/TokenList.tsx index eb52600e..ca9c9ffb 100644 --- a/components/TokenList.tsx +++ b/components/TokenList.tsx @@ -34,6 +34,7 @@ import BankAmountWithValue from './shared/BankAmountWithValue' import useBanksWithBalances, { BankWithBalance, } from 'hooks/useBanksWithBalances' +import useUnownedAccount from 'hooks/useUnownedAccount' const TokenList = () => { const { t } = useTranslation(['common', 'token', 'trade']) @@ -399,7 +400,7 @@ const ActionsMenu = ({ const router = useRouter() const { mangoTokens } = useJupiterMints() const spotMarkets = mangoStore((s) => s.serumMarkets) - const { connected } = useWallet() + const isUnownedAccount = useUnownedAccount() const spotMarket = useMemo(() => { return spotMarkets.find((m) => { @@ -477,7 +478,7 @@ const ActionsMenu = ({ return ( <> - {mangoAccount && !connected ? null : ( + {isUnownedAccount ? null : ( } postion="leftBottom" diff --git a/components/TopBar.tsx b/components/TopBar.tsx index 1be20b6d..bd81d5f5 100644 --- a/components/TopBar.tsx +++ b/components/TopBar.tsx @@ -24,6 +24,7 @@ import DepositWithdrawModal from './modals/DepositWithdrawModal' import { useViewport } from 'hooks/useViewport' import { breakpoints } from 'utils/theme' import AccountsButton from './AccountsButton' +import useUnownedAccount from 'hooks/useUnownedAccount' // import ThemeSwitcher from './ThemeSwitcher' const TopBar = () => { @@ -41,6 +42,7 @@ const TopBar = () => { const { query } = router const { width } = useViewport() const isMobile = width ? width < breakpoints.sm : false + const isUnownedAccount = useUnownedAccount() const handleCloseSetup = useCallback(() => { setShowUserSetup(false) @@ -77,7 +79,7 @@ const TopBar = () => { ) : null} next @@ -112,7 +114,7 @@ const TopBar = () => { {/*
*/} - {(mangoAccount && !connected) || (!connected && isMobile) ? null : ( + {isUnownedAccount || (!connected && isMobile) ? null : (
- + diff --git a/components/modals/PnlHistoryModal.tsx b/components/modals/PnlHistoryModal.tsx index e6b72b5b..d7d420fa 100644 --- a/components/modals/PnlHistoryModal.tsx +++ b/components/modals/PnlHistoryModal.tsx @@ -33,7 +33,7 @@ const PnlHistoryModal = ({ useEffect(() => { if (mangoAccountAddress) { - actions.fetchAccountPerformance(mangoAccountAddress, 30) + actions.fetchAccountPerformance(mangoAccountAddress, 31) } }, [actions, mangoAccountAddress]) @@ -41,8 +41,10 @@ const PnlHistoryModal = ({ if (!performanceData.length) return [] const dailyPnl = performanceData.filter((d: PerformanceDataItem) => { - const date = new Date(d.time) - return date.getHours() === 0 + const startTime = new Date().getTime() - 30 * 86400000 + const dataDate = new Date(d.time) + const dataTime = dataDate.getTime() + return dataTime >= startTime && dataDate.getHours() === 0 }) return dailyPnl.length diff --git a/components/settings/DisplaySettings.tsx b/components/settings/DisplaySettings.tsx index 3134ed09..a4151afd 100644 --- a/components/settings/DisplaySettings.tsx +++ b/components/settings/DisplaySettings.tsx @@ -107,7 +107,7 @@ const DisplaySettings = () => { />
*/} -
+

{t('settings:notification-position')}