From 5f61a624c62c37b245ff38bde9bd155794ab8da4 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 21 Jun 2023 16:28:51 -0500 Subject: [PATCH] Remove legacy useAccount hook --- .../features/feed-suggestions/feed-suggestions.tsx | 14 +++++++++----- .../modals/report-modal/report-modal.tsx | 5 +++-- app/soapbox/hooks/index.ts | 1 - app/soapbox/hooks/useAccount.ts | 8 -------- 4 files changed, 12 insertions(+), 16 deletions(-) delete mode 100644 app/soapbox/hooks/useAccount.ts diff --git a/app/soapbox/features/feed-suggestions/feed-suggestions.tsx b/app/soapbox/features/feed-suggestions/feed-suggestions.tsx index ce86d1432..cac53d103 100644 --- a/app/soapbox/features/feed-suggestions/feed-suggestions.tsx +++ b/app/soapbox/features/feed-suggestions/feed-suggestions.tsx @@ -2,21 +2,25 @@ import React from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { Link } from 'react-router-dom'; +import { useAccount } from 'soapbox/api/hooks'; import VerificationBadge from 'soapbox/components/verification-badge'; -import { useAccount, useAppSelector } from 'soapbox/hooks'; +import { useAppSelector } from 'soapbox/hooks'; import { Card, CardBody, CardTitle, HStack, Stack, Text } from '../../components/ui'; import ActionButton from '../ui/components/action-button'; -import type { Account } from 'soapbox/types/entities'; - const messages = defineMessages({ heading: { id: 'feed_suggestions.heading', defaultMessage: 'Suggested Profiles' }, viewAll: { id: 'feed_suggestions.view_all', defaultMessage: 'View all' }, }); -const SuggestionItem = ({ accountId }: { accountId: string }) => { - const account = useAccount(accountId) as Account; +interface ISuggestionItem { + accountId: string +} + +const SuggestionItem: React.FC = ({ accountId }) => { + const { account } = useAccount(accountId); + if (!account) return null; return ( diff --git a/app/soapbox/features/ui/components/modals/report-modal/report-modal.tsx b/app/soapbox/features/ui/components/modals/report-modal/report-modal.tsx index 566e75981..4b599c445 100644 --- a/app/soapbox/features/ui/components/modals/report-modal/report-modal.tsx +++ b/app/soapbox/features/ui/components/modals/report-modal/report-modal.tsx @@ -4,13 +4,14 @@ import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { blockAccount } from 'soapbox/actions/accounts'; import { submitReport, submitReportSuccess, submitReportFail, ReportableEntities } from 'soapbox/actions/reports'; import { expandAccountTimeline } from 'soapbox/actions/timelines'; +import { useAccount } from 'soapbox/api/hooks'; import AttachmentThumbs from 'soapbox/components/attachment-thumbs'; import GroupCard from 'soapbox/components/group-card'; import List, { ListItem } from 'soapbox/components/list'; import StatusContent from 'soapbox/components/status-content'; import { Avatar, HStack, Icon, Modal, ProgressBar, Stack, Text } from 'soapbox/components/ui'; import AccountContainer from 'soapbox/containers/account-container'; -import { useAccount, useAppDispatch, useAppSelector } from 'soapbox/hooks'; +import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; import ConfirmationStep from './steps/confirmation-step'; import OtherActionsStep from './steps/other-actions-step'; @@ -100,7 +101,7 @@ const ReportModal = ({ onClose }: IReportModal) => { const intl = useIntl(); const accountId = useAppSelector((state) => state.reports.new.account_id); - const account = useAccount(accountId as string); + const { account } = useAccount(accountId || undefined); const entityType = useAppSelector((state) => state.reports.new.entityType); const isBlocked = useAppSelector((state) => state.reports.new.block); diff --git a/app/soapbox/hooks/index.ts b/app/soapbox/hooks/index.ts index 0bd63eb21..4bab834e3 100644 --- a/app/soapbox/hooks/index.ts +++ b/app/soapbox/hooks/index.ts @@ -1,4 +1,3 @@ -export { useAccount } from './useAccount'; export { useApi } from './useApi'; export { useAppDispatch } from './useAppDispatch'; export { useAppSelector } from './useAppSelector'; diff --git a/app/soapbox/hooks/useAccount.ts b/app/soapbox/hooks/useAccount.ts deleted file mode 100644 index e8dfff152..000000000 --- a/app/soapbox/hooks/useAccount.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { useAppSelector } from 'soapbox/hooks'; -import { makeGetAccount } from 'soapbox/selectors'; - -export const useAccount = (id: string) => { - const getAccount = makeGetAccount(); - - return useAppSelector((state) => getAccount(state, id)); -};