diff --git a/app/soapbox/api.ts b/app/soapbox/api.ts index 6de6462bc..bfa07b71a 100644 --- a/app/soapbox/api.ts +++ b/app/soapbox/api.ts @@ -83,7 +83,7 @@ export default (getState: () => RootState, authType: string = 'user'): AxiosInst const state = getState(); const accessToken = getToken(state, authType); const me = state.me; - const baseURL = getAuthBaseURL(state, me); + const baseURL = me ? getAuthBaseURL(state, me) : ''; return baseClient(accessToken, baseURL); }; diff --git a/app/soapbox/features/status/components/action-bar.tsx b/app/soapbox/features/status/components/action-bar.tsx index a230fc5cd..96d25edd6 100644 --- a/app/soapbox/features/status/components/action-bar.tsx +++ b/app/soapbox/features/status/components/action-bar.tsx @@ -66,7 +66,7 @@ const messages = defineMessages({ const mapStateToProps = (state: RootState) => { const me = state.me; - const account = state.accounts.get(me as any); + const account = state.accounts.get(me); const instance = state.instance; return { diff --git a/app/soapbox/features/ui/components/profile-dropdown.tsx b/app/soapbox/features/ui/components/profile-dropdown.tsx index b69f19314..850f54611 100644 --- a/app/soapbox/features/ui/components/profile-dropdown.tsx +++ b/app/soapbox/features/ui/components/profile-dropdown.tsx @@ -7,7 +7,7 @@ import { Link } from 'react-router-dom'; import { logOut, switchAccount } from 'soapbox/actions/auth'; import { fetchOwnAccounts } from 'soapbox/actions/auth'; import { Menu, MenuButton, MenuDivider, MenuItem, MenuLink, MenuList } from 'soapbox/components/ui'; -import { useAppSelector } from 'soapbox/hooks'; +import { useAppSelector, useOwnAccount } from 'soapbox/hooks'; import { makeGetAccount } from 'soapbox/selectors'; import Account from '../../../components/account'; @@ -36,8 +36,7 @@ const ProfileDropdown: React.FC = ({ account, children }) => { const dispatch = useDispatch(); const intl = useIntl(); - const me = useAppSelector((state) => state.me); - const currentAccount = useAppSelector((state) => getAccount(state, me)); + const currentAccount = useOwnAccount(); const authUsers = useAppSelector((state) => state.auth.get('users')); const isCurrentAccountStaff = Boolean(currentAccount?.staff); const otherAccounts = useAppSelector((state) => authUsers.map((authUser: any) => getAccount(state, authUser.get('id')))); diff --git a/app/soapbox/features/ui/components/sign_up_panel.tsx b/app/soapbox/features/ui/components/sign_up_panel.tsx index 44656f40e..2a54c5c11 100644 --- a/app/soapbox/features/ui/components/sign_up_panel.tsx +++ b/app/soapbox/features/ui/components/sign_up_panel.tsx @@ -1,15 +1,13 @@ import React from 'react'; import { FormattedMessage } from 'react-intl'; -import { getSoapboxConfig } from 'soapbox/actions/soapbox'; import { Button, Stack, Text } from 'soapbox/components/ui'; -import { useAppSelector } from 'soapbox/hooks'; +import { useAppSelector, useSoapboxConfig } from 'soapbox/hooks'; const SignUpPanel = () => { - const soapboxConfig = useAppSelector((state) => getSoapboxConfig(state)); - const siteTitle: string = useAppSelector((state) => state.instance.title); - const me: boolean | null = useAppSelector((state) => state.me); - const singleUserMode: boolean = soapboxConfig.get('singleUserMode'); + const { singleUserMode } = useSoapboxConfig(); + const siteTitle = useAppSelector((state) => state.instance.title); + const me = useAppSelector((state) => state.me); if (me || singleUserMode) return null; diff --git a/app/soapbox/reducers/accounts.ts b/app/soapbox/reducers/accounts.ts index 781385858..ddc3a813b 100644 --- a/app/soapbox/reducers/accounts.ts +++ b/app/soapbox/reducers/accounts.ts @@ -49,7 +49,7 @@ export interface ReducerAccount extends AccountRecord { moved: string | null, } -type State = ImmutableMap; +type State = ImmutableMap; const initialState: State = ImmutableMap();