diff --git a/app/soapbox/api/hooks/groups/useCancelMembershipRequest.ts b/app/soapbox/api/hooks/groups/useCancelMembershipRequest.ts index 2c6007c51..51c480731 100644 --- a/app/soapbox/api/hooks/groups/useCancelMembershipRequest.ts +++ b/app/soapbox/api/hooks/groups/useCancelMembershipRequest.ts @@ -6,7 +6,7 @@ import type { Group } from 'soapbox/schemas'; function useCancelMembershipRequest(group: Group) { const api = useApi(); - const me = useOwnAccount(); + const { account: me } = useOwnAccount(); const { createEntity, isSubmitting } = useCreateEntity( [Entities.GROUP_RELATIONSHIPS], diff --git a/app/soapbox/components/sidebar-navigation.tsx b/app/soapbox/components/sidebar-navigation.tsx index 65360cbf6..3dadaeab1 100644 --- a/app/soapbox/components/sidebar-navigation.tsx +++ b/app/soapbox/components/sidebar-navigation.tsx @@ -24,7 +24,7 @@ const SidebarNavigation = () => { const features = useFeatures(); const settings = useSettings(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const groupsPath = useGroupsPath(); const notificationCount = useAppSelector((state) => state.notifications.unread); diff --git a/app/soapbox/components/status-action-bar.tsx b/app/soapbox/components/status-action-bar.tsx index 3e6cae67a..0d1602405 100644 --- a/app/soapbox/components/status-action-bar.tsx +++ b/app/soapbox/components/status-action-bar.tsx @@ -123,7 +123,7 @@ const StatusActionBar: React.FC = ({ const { allowedEmoji } = soapboxConfig; - const account = useOwnAccount(); + const { account } = useOwnAccount(); const isStaff = account ? account.staff : false; const isAdmin = account ? account.admin : false; diff --git a/app/soapbox/components/status-reaction-wrapper.tsx b/app/soapbox/components/status-reaction-wrapper.tsx index 206cd1fed..236653307 100644 --- a/app/soapbox/components/status-reaction-wrapper.tsx +++ b/app/soapbox/components/status-reaction-wrapper.tsx @@ -15,7 +15,7 @@ interface IStatusReactionWrapper { /** Provides emoji reaction functionality to the underlying button component */ const StatusReactionWrapper: React.FC = ({ statusId, children }): JSX.Element | null => { const dispatch = useAppDispatch(); - const ownAccount = useOwnAccount(); + const { account: ownAccount } = useOwnAccount(); const status = useAppSelector(state => state.statuses.get(statusId)); const soapboxConfig = useSoapboxConfig(); diff --git a/app/soapbox/components/statuses/sensitive-content-overlay.tsx b/app/soapbox/components/statuses/sensitive-content-overlay.tsx index 96539a05f..bf5dc7d82 100644 --- a/app/soapbox/components/statuses/sensitive-content-overlay.tsx +++ b/app/soapbox/components/statuses/sensitive-content-overlay.tsx @@ -35,7 +35,7 @@ interface ISensitiveContentOverlay { const SensitiveContentOverlay = React.forwardRef((props, ref) => { const { onToggleVisibility, status } = props; - const account = useOwnAccount(); + const { account } = useOwnAccount(); const dispatch = useAppDispatch(); const intl = useIntl(); const settings = useSettings(); diff --git a/app/soapbox/components/thumb-navigation.tsx b/app/soapbox/components/thumb-navigation.tsx index 013ecece7..52b3a4c50 100644 --- a/app/soapbox/components/thumb-navigation.tsx +++ b/app/soapbox/components/thumb-navigation.tsx @@ -6,7 +6,7 @@ import { useStatContext } from 'soapbox/contexts/stat-context'; import { useAppSelector, useFeatures, useGroupsPath, useOwnAccount } from 'soapbox/hooks'; const ThumbNavigation: React.FC = (): JSX.Element => { - const account = useOwnAccount(); + const { account } = useOwnAccount(); const features = useFeatures(); const groupsPath = useGroupsPath(); diff --git a/app/soapbox/containers/soapbox.tsx b/app/soapbox/containers/soapbox.tsx index 6048be71d..aa935624d 100644 --- a/app/soapbox/containers/soapbox.tsx +++ b/app/soapbox/containers/soapbox.tsx @@ -91,7 +91,7 @@ const SoapboxMount = () => { const me = useAppSelector(state => state.me); const instance = useInstance(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const soapboxConfig = useSoapboxConfig(); const features = useFeatures(); const { pepeEnabled } = useRegistrationStatus(); @@ -217,7 +217,7 @@ const SoapboxLoad: React.FC = ({ children }) => { const dispatch = useAppDispatch(); const me = useAppSelector(state => state.me); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const swUpdating = useAppSelector(state => state.meta.swUpdating); const { locale } = useLocale(); diff --git a/app/soapbox/contexts/chat-context.tsx b/app/soapbox/contexts/chat-context.tsx index 5c60c68d0..0080660d0 100644 --- a/app/soapbox/contexts/chat-context.tsx +++ b/app/soapbox/contexts/chat-context.tsx @@ -27,7 +27,7 @@ const ChatProvider: React.FC = ({ children }) => { const history = useHistory(); const dispatch = useAppDispatch(); const settings = useSettings(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const path = history.location.pathname; const isUsingMainChatPage = Boolean(path.match(/^\/chats/)); diff --git a/app/soapbox/features/account/components/header.tsx b/app/soapbox/features/account/components/header.tsx index 3f7c175a7..bbf494f34 100644 --- a/app/soapbox/features/account/components/header.tsx +++ b/app/soapbox/features/account/components/header.tsx @@ -87,7 +87,7 @@ const Header: React.FC = ({ account }) => { const dispatch = useAppDispatch(); const features = useFeatures(); - const ownAccount = useOwnAccount(); + const { account: ownAccount } = useOwnAccount(); const { follow } = useFollow(); const { software } = useAppSelector((state) => parseVersion(state.instance.version)); diff --git a/app/soapbox/features/admin/index.tsx b/app/soapbox/features/admin/index.tsx index 46a146c9f..c8286b393 100644 --- a/app/soapbox/features/admin/index.tsx +++ b/app/soapbox/features/admin/index.tsx @@ -16,7 +16,7 @@ const messages = defineMessages({ const Admin: React.FC = () => { const intl = useIntl(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); if (!account) return null; diff --git a/app/soapbox/features/admin/tabs/dashboard.tsx b/app/soapbox/features/admin/tabs/dashboard.tsx index 1d5a53e95..9f7279a40 100644 --- a/app/soapbox/features/admin/tabs/dashboard.tsx +++ b/app/soapbox/features/admin/tabs/dashboard.tsx @@ -18,7 +18,7 @@ const Dashboard: React.FC = () => { const history = useHistory(); const instance = useInstance(); const features = useFeatures(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const handleSubscribersClick: React.MouseEventHandler = e => { dispatch(getSubscribersCsv()).then(({ data }) => { diff --git a/app/soapbox/features/aliases/index.tsx b/app/soapbox/features/aliases/index.tsx index d9e5ac52d..d77975360 100644 --- a/app/soapbox/features/aliases/index.tsx +++ b/app/soapbox/features/aliases/index.tsx @@ -23,7 +23,7 @@ const Aliases = () => { const intl = useIntl(); const dispatch = useAppDispatch(); const features = useFeatures(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const aliases = useAppSelector((state) => { if (features.accountMoving) { diff --git a/app/soapbox/features/auth-layout/index.tsx b/app/soapbox/features/auth-layout/index.tsx index 4b1cad917..9ad78c184 100644 --- a/app/soapbox/features/auth-layout/index.tsx +++ b/app/soapbox/features/auth-layout/index.tsx @@ -26,7 +26,7 @@ const AuthLayout = () => { const history = useHistory(); const { search } = useLocation(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const instance = useInstance(); const { isOpen } = useRegistrationStatus(); const isLoginPage = history.location.pathname === '/login'; diff --git a/app/soapbox/features/chats/components/chat-message-list.tsx b/app/soapbox/features/chats/components/chat-message-list.tsx index 4e854523e..b06c34664 100644 --- a/app/soapbox/features/chats/components/chat-message-list.tsx +++ b/app/soapbox/features/chats/components/chat-message-list.tsx @@ -69,7 +69,7 @@ interface IChatMessageList { /** Scrollable list of chat messages. */ const ChatMessageList: React.FC = ({ chat }) => { const intl = useIntl(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const myLastReadMessageDateString = chat.latest_read_message_by_account?.find((latest) => latest.id === account?.id)?.date; const myLastReadMessageTimestamp = myLastReadMessageDateString ? new Date(myLastReadMessageDateString) : null; diff --git a/app/soapbox/features/chats/components/chat-page/chat-page.tsx b/app/soapbox/features/chats/components/chat-page/chat-page.tsx index 746494623..b2cf7bed7 100644 --- a/app/soapbox/features/chats/components/chat-page/chat-page.tsx +++ b/app/soapbox/features/chats/components/chat-page/chat-page.tsx @@ -16,7 +16,7 @@ interface IChatPage { } const ChatPage: React.FC = ({ chatId }) => { - const account = useOwnAccount(); + const { account } = useOwnAccount(); const history = useHistory(); const isOnboarded = account?.source?.chats_onboarded ?? true; diff --git a/app/soapbox/features/chats/components/chat-page/components/chat-page-settings.tsx b/app/soapbox/features/chats/components/chat-page/components/chat-page-settings.tsx index 097120f52..dddff635e 100644 --- a/app/soapbox/features/chats/components/chat-page/components/chat-page-settings.tsx +++ b/app/soapbox/features/chats/components/chat-page/components/chat-page-settings.tsx @@ -24,7 +24,7 @@ const messages = defineMessages({ }); const ChatPageSettings = () => { - const account = useOwnAccount(); + const { account } = useOwnAccount(); const intl = useIntl(); const history = useHistory(); const dispatch = useAppDispatch(); diff --git a/app/soapbox/features/chats/components/chat-page/components/welcome.tsx b/app/soapbox/features/chats/components/chat-page/components/welcome.tsx index 187039eb8..bd5c1ccf0 100644 --- a/app/soapbox/features/chats/components/chat-page/components/welcome.tsx +++ b/app/soapbox/features/chats/components/chat-page/components/welcome.tsx @@ -20,7 +20,7 @@ const messages = defineMessages({ }); const Welcome = () => { - const account = useOwnAccount(); + const { account } = useOwnAccount(); const intl = useIntl(); const updateCredentials = useUpdateCredentials(); diff --git a/app/soapbox/features/chats/components/chat-widget/chat-widget.tsx b/app/soapbox/features/chats/components/chat-widget/chat-widget.tsx index 038bab90e..05b9fb255 100644 --- a/app/soapbox/features/chats/components/chat-widget/chat-widget.tsx +++ b/app/soapbox/features/chats/components/chat-widget/chat-widget.tsx @@ -7,7 +7,7 @@ import { useOwnAccount } from 'soapbox/hooks'; import ChatPane from '../chat-pane/chat-pane'; const ChatWidget = () => { - const account = useOwnAccount(); + const { account } = useOwnAccount(); const history = useHistory(); const path = history.location.pathname; diff --git a/app/soapbox/features/developers/apps/create.tsx b/app/soapbox/features/developers/apps/create.tsx index d69184909..24e1de995 100644 --- a/app/soapbox/features/developers/apps/create.tsx +++ b/app/soapbox/features/developers/apps/create.tsx @@ -25,7 +25,7 @@ type Params = typeof BLANK_PARAMS; const CreateApp: React.FC = () => { const intl = useIntl(); const dispatch = useAppDispatch(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const [app, setApp] = useState | null>(null); const [token, setToken] = useState(null); diff --git a/app/soapbox/features/edit-profile/index.tsx b/app/soapbox/features/edit-profile/index.tsx index 6a1f1b5d3..721879068 100644 --- a/app/soapbox/features/edit-profile/index.tsx +++ b/app/soapbox/features/edit-profile/index.tsx @@ -177,7 +177,7 @@ const EditProfile: React.FC = () => { const dispatch = useAppDispatch(); const instance = useInstance(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const features = useFeatures(); const maxFields = instance.pleroma.getIn(['metadata', 'fields_limits', 'max_fields'], 4) as number; diff --git a/app/soapbox/features/event/components/event-header.tsx b/app/soapbox/features/event/components/event-header.tsx index 8e8cf9ca3..e34114980 100644 --- a/app/soapbox/features/event/components/event-header.tsx +++ b/app/soapbox/features/event/components/event-header.tsx @@ -73,7 +73,7 @@ const EventHeader: React.FC = ({ status }) => { const features = useFeatures(); const settings = useSettings(); - const ownAccount = useOwnAccount(); + const { account: ownAccount } = useOwnAccount(); const isStaff = ownAccount ? ownAccount.staff : false; const isAdmin = ownAccount ? ownAccount.admin : false; diff --git a/app/soapbox/features/favourited-statuses/index.tsx b/app/soapbox/features/favourited-statuses/index.tsx index 71d76fb21..a504eb258 100644 --- a/app/soapbox/features/favourited-statuses/index.tsx +++ b/app/soapbox/features/favourited-statuses/index.tsx @@ -26,7 +26,7 @@ const Favourites: React.FC = ({ params }) => { const intl = useIntl(); const dispatch = useAppDispatch(); const features = useFeatures(); - const ownAccount = useOwnAccount(); + const { account: ownAccount } = useOwnAccount(); const { account } = useAccount(params?.username, { withRelationship: true }); const username = params?.username || ''; diff --git a/app/soapbox/features/followers/index.tsx b/app/soapbox/features/followers/index.tsx index 55ff903f8..87049b473 100644 --- a/app/soapbox/features/followers/index.tsx +++ b/app/soapbox/features/followers/index.tsx @@ -31,7 +31,7 @@ const Followers: React.FC = (props) => { const intl = useIntl(); const dispatch = useAppDispatch(); const features = useFeatures(); - const ownAccount = useOwnAccount(); + const { account: ownAccount } = useOwnAccount(); const [loading, setLoading] = useState(true); diff --git a/app/soapbox/features/following/index.tsx b/app/soapbox/features/following/index.tsx index 7f2b51236..166fcc3ee 100644 --- a/app/soapbox/features/following/index.tsx +++ b/app/soapbox/features/following/index.tsx @@ -31,7 +31,7 @@ const Following: React.FC = (props) => { const intl = useIntl(); const dispatch = useAppDispatch(); const features = useFeatures(); - const ownAccount = useOwnAccount(); + const { account: ownAccount } = useOwnAccount(); const [loading, setLoading] = useState(true); diff --git a/app/soapbox/features/group/components/group-action-button.tsx b/app/soapbox/features/group/components/group-action-button.tsx index f3b208574..a5c335909 100644 --- a/app/soapbox/features/group/components/group-action-button.tsx +++ b/app/soapbox/features/group/components/group-action-button.tsx @@ -31,7 +31,7 @@ const messages = defineMessages({ const GroupActionButton = ({ group }: IGroupActionButton) => { const dispatch = useAppDispatch(); const intl = useIntl(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const joinGroup = useJoinGroup(group); const leaveGroup = useLeaveGroup(group); diff --git a/app/soapbox/features/group/components/group-options-button.tsx b/app/soapbox/features/group/components/group-options-button.tsx index ebc3152e4..1f4373056 100644 --- a/app/soapbox/features/group/components/group-options-button.tsx +++ b/app/soapbox/features/group/components/group-options-button.tsx @@ -27,7 +27,7 @@ interface IGroupActionButton { } const GroupOptionsButton = ({ group }: IGroupActionButton) => { - const account = useOwnAccount(); + const { account } = useOwnAccount(); const dispatch = useAppDispatch(); const intl = useIntl(); const leaveGroup = useLeaveGroup(group); diff --git a/app/soapbox/features/group/group-timeline.tsx b/app/soapbox/features/group/group-timeline.tsx index 3c736cd78..75b7a95d3 100644 --- a/app/soapbox/features/group/group-timeline.tsx +++ b/app/soapbox/features/group/group-timeline.tsx @@ -24,7 +24,7 @@ const getStatusIds = makeGetStatusIds(); const GroupTimeline: React.FC = (props) => { const intl = useIntl(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const dispatch = useAppDispatch(); const composer = useRef(null); diff --git a/app/soapbox/features/groups/components/discover/search/recent-searches.tsx b/app/soapbox/features/groups/components/discover/search/recent-searches.tsx index 44f134b4c..e27bdaef9 100644 --- a/app/soapbox/features/groups/components/discover/search/recent-searches.tsx +++ b/app/soapbox/features/groups/components/discover/search/recent-searches.tsx @@ -14,7 +14,7 @@ interface Props { export default (props: Props) => { const { onSelect } = props; - const me = useOwnAccount(); + const { account: me } = useOwnAccount(); const [recentSearches, setRecentSearches] = useState(groupSearchHistory.get(me?.id as string) || []); diff --git a/app/soapbox/features/groups/components/discover/search/search.tsx b/app/soapbox/features/groups/components/discover/search/search.tsx index 0e2d7f00e..01ba22856 100644 --- a/app/soapbox/features/groups/components/discover/search/search.tsx +++ b/app/soapbox/features/groups/components/discover/search/search.tsx @@ -19,7 +19,7 @@ interface Props { export default (props: Props) => { const { onSelect, searchValue } = props; - const me = useOwnAccount(); + const { account: me } = useOwnAccount(); const debounce = useDebounce; const debouncedValue = debounce(searchValue as string, 300); diff --git a/app/soapbox/features/onboarding/steps/avatar-selection-step.tsx b/app/soapbox/features/onboarding/steps/avatar-selection-step.tsx index 32c69115f..55a54c514 100644 --- a/app/soapbox/features/onboarding/steps/avatar-selection-step.tsx +++ b/app/soapbox/features/onboarding/steps/avatar-selection-step.tsx @@ -17,7 +17,7 @@ const messages = defineMessages({ const AvatarSelectionStep = ({ onNext }: { onNext: () => void }) => { const dispatch = useAppDispatch(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const fileInput = React.useRef(null); const [selectedFile, setSelectedFile] = React.useState(); diff --git a/app/soapbox/features/onboarding/steps/bio-step.tsx b/app/soapbox/features/onboarding/steps/bio-step.tsx index eee5be200..c0a029d80 100644 --- a/app/soapbox/features/onboarding/steps/bio-step.tsx +++ b/app/soapbox/features/onboarding/steps/bio-step.tsx @@ -17,7 +17,7 @@ const BioStep = ({ onNext }: { onNext: () => void }) => { const intl = useIntl(); const dispatch = useAppDispatch(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const [value, setValue] = React.useState(account?.source?.note ?? ''); const [isSubmitting, setSubmitting] = React.useState(false); const [errors, setErrors] = React.useState([]); diff --git a/app/soapbox/features/onboarding/steps/cover-photo-selection-step.tsx b/app/soapbox/features/onboarding/steps/cover-photo-selection-step.tsx index c48cd3c1f..5e9c314f8 100644 --- a/app/soapbox/features/onboarding/steps/cover-photo-selection-step.tsx +++ b/app/soapbox/features/onboarding/steps/cover-photo-selection-step.tsx @@ -20,7 +20,7 @@ const messages = defineMessages({ const CoverPhotoSelectionStep = ({ onNext }: { onNext: () => void }) => { const intl = useIntl(); const dispatch = useAppDispatch(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const fileInput = React.useRef(null); const [selectedFile, setSelectedFile] = React.useState(); diff --git a/app/soapbox/features/onboarding/steps/display-name-step.tsx b/app/soapbox/features/onboarding/steps/display-name-step.tsx index a94e4f7c9..f9916396f 100644 --- a/app/soapbox/features/onboarding/steps/display-name-step.tsx +++ b/app/soapbox/features/onboarding/steps/display-name-step.tsx @@ -17,7 +17,7 @@ const DisplayNameStep = ({ onNext }: { onNext: () => void }) => { const intl = useIntl(); const dispatch = useAppDispatch(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const [value, setValue] = React.useState(account?.display_name || ''); const [isSubmitting, setSubmitting] = React.useState(false); const [errors, setErrors] = React.useState([]); diff --git a/app/soapbox/features/onboarding/steps/fediverse-step.tsx b/app/soapbox/features/onboarding/steps/fediverse-step.tsx index ba5de74e4..a8849a9f5 100644 --- a/app/soapbox/features/onboarding/steps/fediverse-step.tsx +++ b/app/soapbox/features/onboarding/steps/fediverse-step.tsx @@ -5,10 +5,8 @@ import Account from 'soapbox/components/account'; import { Button, Card, CardBody, Icon, Stack, Text } from 'soapbox/components/ui'; import { useInstance, useOwnAccount } from 'soapbox/hooks'; -import type { Account as AccountEntity } from 'soapbox/types/entities'; - const FediverseStep = ({ onNext }: { onNext: () => void }) => { - const account = useOwnAccount() as AccountEntity; + const { account } = useOwnAccount(); const instance = useInstance(); return ( @@ -49,9 +47,11 @@ const FediverseStep = ({ onNext }: { onNext: () => void }) => { -
- -
+ {account && ( +
+ +
+ )} { const intl = useIntl(); const features = useFeatures(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const soapboxConfig = useSoapboxConfig(); const { isOpen } = useRegistrationStatus(); const { links } = soapboxConfig; diff --git a/app/soapbox/features/settings/components/messages-settings.tsx b/app/soapbox/features/settings/components/messages-settings.tsx index 8c7dda248..2e7293542 100644 --- a/app/soapbox/features/settings/components/messages-settings.tsx +++ b/app/soapbox/features/settings/components/messages-settings.tsx @@ -11,7 +11,7 @@ const messages = defineMessages({ }); const MessagesSettings = () => { - const account = useOwnAccount(); + const { account } = useOwnAccount(); const intl = useIntl(); const updateCredentials = useUpdateCredentials(); diff --git a/app/soapbox/features/settings/index.tsx b/app/soapbox/features/settings/index.tsx index 6ebc8eacf..8c9877de4 100644 --- a/app/soapbox/features/settings/index.tsx +++ b/app/soapbox/features/settings/index.tsx @@ -40,7 +40,7 @@ const Settings = () => { const mfa = useAppSelector((state) => state.security.get('mfa')); const features = useFeatures(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const navigateToChangeEmail = () => history.push('/settings/email'); const navigateToChangePassword = () => history.push('/settings/password'); diff --git a/app/soapbox/features/status/components/thread.tsx b/app/soapbox/features/status/components/thread.tsx index aa563e839..058f02a08 100644 --- a/app/soapbox/features/status/components/thread.tsx +++ b/app/soapbox/features/status/components/thread.tsx @@ -97,7 +97,7 @@ const Thread = (props: IThread) => { const dispatch = useAppDispatch(); const history = useHistory(); const intl = useIntl(); - const me = useOwnAccount(); + const { account: me } = useOwnAccount(); const settings = useSettings(); const displayMedia = settings.get('displayMedia') as DisplayMedia; diff --git a/app/soapbox/features/ui/components/instance-moderation-panel.tsx b/app/soapbox/features/ui/components/instance-moderation-panel.tsx index b3c2ce1c2..4143f14d4 100644 --- a/app/soapbox/features/ui/components/instance-moderation-panel.tsx +++ b/app/soapbox/features/ui/components/instance-moderation-panel.tsx @@ -26,7 +26,7 @@ const InstanceModerationPanel: React.FC = ({ host }) = const intl = useIntl(); const dispatch = useAppDispatch(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const remoteInstance = useAppSelector(state => getRemoteInstance(state, host)); const handleEditFederation = () => { diff --git a/app/soapbox/features/ui/components/link-footer.tsx b/app/soapbox/features/ui/components/link-footer.tsx index 377234093..402f49e97 100644 --- a/app/soapbox/features/ui/components/link-footer.tsx +++ b/app/soapbox/features/ui/components/link-footer.tsx @@ -25,7 +25,7 @@ const FooterLink: React.FC = ({ children, className, ...rest }): JS }; const LinkFooter: React.FC = (): JSX.Element => { - const account = useOwnAccount(); + const { account } = useOwnAccount(); const features = useFeatures(); const soapboxConfig = useSoapboxConfig(); diff --git a/app/soapbox/features/ui/components/modals/account-moderation-modal/account-moderation-modal.tsx b/app/soapbox/features/ui/components/modals/account-moderation-modal/account-moderation-modal.tsx index f7f1606aa..016759205 100644 --- a/app/soapbox/features/ui/components/modals/account-moderation-modal/account-moderation-modal.tsx +++ b/app/soapbox/features/ui/components/modals/account-moderation-modal/account-moderation-modal.tsx @@ -45,7 +45,7 @@ const AccountModerationModal: React.FC = ({ onClose, ac const intl = useIntl(); const dispatch = useAppDispatch(); - const ownAccount = useOwnAccount(); + const { account: ownAccount } = useOwnAccount(); const features = useFeatures(); const { account } = useAccount(accountId); diff --git a/app/soapbox/features/ui/components/navbar.tsx b/app/soapbox/features/ui/components/navbar.tsx index 422d22561..84bab5516 100644 --- a/app/soapbox/features/ui/components/navbar.tsx +++ b/app/soapbox/features/ui/components/navbar.tsx @@ -28,7 +28,7 @@ const Navbar = () => { const intl = useIntl(); const features = useFeatures(); const { isOpen } = useRegistrationStatus(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const node = useRef(null); const [isLoading, setLoading] = useState(false); diff --git a/app/soapbox/features/ui/index.tsx b/app/soapbox/features/ui/index.tsx index b3ad6b8bf..847b29d26 100644 --- a/app/soapbox/features/ui/index.tsx +++ b/app/soapbox/features/ui/index.tsx @@ -399,7 +399,7 @@ const UI: React.FC = ({ children }) => { const hotkeys = useRef(null); const me = useAppSelector(state => state.me); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const features = useFeatures(); const vapidKey = useAppSelector(state => getVapidKey(state)); diff --git a/app/soapbox/features/ui/util/react-router-helpers.tsx b/app/soapbox/features/ui/util/react-router-helpers.tsx index 994278e84..30ba2a1f5 100644 --- a/app/soapbox/features/ui/util/react-router-helpers.tsx +++ b/app/soapbox/features/ui/util/react-router-helpers.tsx @@ -42,7 +42,7 @@ const WrappedRoute: React.FC = ({ }) => { const history = useHistory(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const settings = useSettings(); const renderComponent = ({ match }: RouteComponentProps) => { diff --git a/app/soapbox/features/verification/waitlist-page.tsx b/app/soapbox/features/verification/waitlist-page.tsx index 5e329f69e..431c76698 100644 --- a/app/soapbox/features/verification/waitlist-page.tsx +++ b/app/soapbox/features/verification/waitlist-page.tsx @@ -13,7 +13,7 @@ const WaitlistPage = () => { const dispatch = useAppDispatch(); const instance = useInstance(); - const me = useOwnAccount(); + const { account: me } = useOwnAccount(); const isSmsVerified = me?.source?.sms_verified ?? true; const onClickLogOut: React.MouseEventHandler = (event) => { diff --git a/app/soapbox/hooks/useOwnAccount.ts b/app/soapbox/hooks/useOwnAccount.ts index 15c6a83af..800f9bb63 100644 --- a/app/soapbox/hooks/useOwnAccount.ts +++ b/app/soapbox/hooks/useOwnAccount.ts @@ -3,19 +3,17 @@ import { useCallback } from 'react'; import { useAppSelector } from 'soapbox/hooks'; import { makeGetAccount } from 'soapbox/selectors'; -import type { Account } from 'soapbox/types/entities'; - /** Get the logged-in account from the store, if any. */ -export const useOwnAccount = (): Account | null => { +export const useOwnAccount = () => { const getAccount = useCallback(makeGetAccount(), []); - return useAppSelector((state) => { + const account = useAppSelector((state) => { const { me } = state; if (typeof me === 'string') { return getAccount(state, me); - } else { - return null; } }); + + return { account: account || undefined }; }; diff --git a/app/soapbox/pages/group-page.tsx b/app/soapbox/pages/group-page.tsx index 1803de51c..8983b57e2 100644 --- a/app/soapbox/pages/group-page.tsx +++ b/app/soapbox/pages/group-page.tsx @@ -96,7 +96,7 @@ const GroupPage: React.FC = ({ params, children }) => { const intl = useIntl(); const features = useFeatures(); const match = useRouteMatch(); - const me = useOwnAccount(); + const { account: me } = useOwnAccount(); const id = params?.groupId || ''; diff --git a/app/soapbox/pages/home-page.tsx b/app/soapbox/pages/home-page.tsx index 1df0572a6..6ed7b8eea 100644 --- a/app/soapbox/pages/home-page.tsx +++ b/app/soapbox/pages/home-page.tsx @@ -32,7 +32,7 @@ const HomePage: React.FC = ({ children }) => { const dispatch = useAppDispatch(); const me = useAppSelector(state => state.me); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const features = useFeatures(); const soapboxConfig = useSoapboxConfig(); diff --git a/app/soapbox/pages/remote-instance-page.tsx b/app/soapbox/pages/remote-instance-page.tsx index d6d305834..cd7338606 100644 --- a/app/soapbox/pages/remote-instance-page.tsx +++ b/app/soapbox/pages/remote-instance-page.tsx @@ -23,7 +23,7 @@ interface IRemoteInstancePage { const RemoteInstancePage: React.FC = ({ children, params }) => { const host = params?.instance; - const account = useOwnAccount(); + const { account } = useOwnAccount(); const disclosed = useAppSelector(federationRestrictionsDisclosed); return ( diff --git a/app/soapbox/queries/accounts.ts b/app/soapbox/queries/accounts.ts index f34d4c72d..2f2d5ba43 100644 --- a/app/soapbox/queries/accounts.ts +++ b/app/soapbox/queries/accounts.ts @@ -35,7 +35,7 @@ type UpdateCredentialsData = { } const useUpdateCredentials = () => { - const account = useOwnAccount(); + const { account } = useOwnAccount(); const api = useApi(); const dispatch = useAppDispatch(); diff --git a/app/soapbox/queries/chats.ts b/app/soapbox/queries/chats.ts index 8256a0dc8..c540577f8 100644 --- a/app/soapbox/queries/chats.ts +++ b/app/soapbox/queries/chats.ts @@ -200,7 +200,7 @@ const useChat = (chatId?: string) => { }; const useChatActions = (chatId: string) => { - const account = useOwnAccount(); + const { account } = useOwnAccount(); const api = useApi(); // const dispatch = useAppDispatch(); diff --git a/app/soapbox/queries/groups.ts b/app/soapbox/queries/groups.ts index 26152892e..a28f8cf87 100644 --- a/app/soapbox/queries/groups.ts +++ b/app/soapbox/queries/groups.ts @@ -48,7 +48,7 @@ const useGroupsApi = () => { const usePendingGroups = () => { const features = useFeatures(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const { fetchGroups } = useGroupsApi(); const getGroups = async (pageParam?: any): Promise> => { diff --git a/app/soapbox/queries/policies.ts b/app/soapbox/queries/policies.ts index f7c97ff53..fc91705a5 100644 --- a/app/soapbox/queries/policies.ts +++ b/app/soapbox/queries/policies.ts @@ -14,7 +14,7 @@ const PolicyKeys = { function usePendingPolicy() { const api = useApi(); - const account = useOwnAccount(); + const { account } = useOwnAccount(); const features = useFeatures(); const getPolicy = async() => {