diff --git a/app/soapbox/components/sidebar-menu.tsx b/app/soapbox/components/sidebar-menu.tsx index 241e3e837..f77e9f5ed 100644 --- a/app/soapbox/components/sidebar-menu.tsx +++ b/app/soapbox/components/sidebar-menu.tsx @@ -1,17 +1,18 @@ /* eslint-disable jsx-a11y/interactive-supports-focus */ import clsx from 'clsx'; -import React from 'react'; +import React, { useCallback } from 'react'; import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; import { Link, NavLink } from 'react-router-dom'; import { fetchOwnAccounts, logOut, switchAccount } from 'soapbox/actions/auth'; import { getSettings } from 'soapbox/actions/settings'; import { closeSidebar } from 'soapbox/actions/sidebar'; +import { useAccount } from 'soapbox/api/hooks'; import Account from 'soapbox/components/account'; import { Stack } from 'soapbox/components/ui'; import ProfileStats from 'soapbox/features/ui/components/profile-stats'; import { useAppDispatch, useAppSelector, useGroupsPath, useFeatures } from 'soapbox/hooks'; -import { makeGetAccount, makeGetOtherAccounts } from 'soapbox/selectors'; +import { makeGetOtherAccounts } from 'soapbox/selectors'; import { Divider, HStack, Icon, IconButton, Text } from './ui'; @@ -76,16 +77,14 @@ const SidebarLink: React.FC = ({ href, to, icon, text, onClick }) ); }; -const getOtherAccounts = makeGetOtherAccounts(); - const SidebarMenu: React.FC = (): JSX.Element | null => { const intl = useIntl(); const dispatch = useAppDispatch(); + const getOtherAccounts = useCallback(makeGetOtherAccounts(), []); const features = useFeatures(); - const getAccount = makeGetAccount(); const me = useAppSelector((state) => state.me); - const account = useAppSelector((state) => me ? getAccount(state, me) : null); + const { account } = useAccount(me || undefined); const otherAccounts: ImmutableList = useAppSelector((state) => getOtherAccounts(state)); const sidebarOpen = useAppSelector((state) => state.sidebar.sidebarOpen); const settings = useAppSelector((state) => getSettings(state)); diff --git a/app/soapbox/features/ui/components/profile-stats.tsx b/app/soapbox/features/ui/components/profile-stats.tsx index d02542b2f..6cb02a173 100644 --- a/app/soapbox/features/ui/components/profile-stats.tsx +++ b/app/soapbox/features/ui/components/profile-stats.tsx @@ -5,7 +5,7 @@ import { NavLink } from 'react-router-dom'; import { HStack, Text } from 'soapbox/components/ui'; import { shortNumberFormat } from 'soapbox/utils/numbers'; -import type { Account } from 'soapbox/types/entities'; +import type { Account } from 'soapbox/schemas'; const messages = defineMessages({ followers: { id: 'account.followers', defaultMessage: 'Followers' }, @@ -13,7 +13,7 @@ const messages = defineMessages({ }); interface IProfileStats { - account: Account | undefined + account: Pick | undefined onClickHandler?: React.MouseEventHandler }