Clean up me usage

This commit is contained in:
Alex Gleason 2022-04-04 14:24:42 -05:00
parent fdb44d615d
commit e88fe4a707
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
5 changed files with 9 additions and 12 deletions

View file

@ -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);
};

View file

@ -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 {

View file

@ -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<IProfileDropdown> = ({ 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'))));

View file

@ -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;

View file

@ -49,7 +49,7 @@ export interface ReducerAccount extends AccountRecord {
moved: string | null,
}
type State = ImmutableMap<string | number, ReducerAccount>;
type State = ImmutableMap<any, ReducerAccount>;
const initialState: State = ImmutableMap();