Hooks: get rid of useAccount, create useOwnAccount
This commit is contained in:
parent
2da31341c4
commit
be690255cb
3 changed files with 6 additions and 6 deletions
|
@ -6,7 +6,7 @@ import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
import { Avatar, Button, Icon } from 'soapbox/components/ui';
|
import { Avatar, Button, Icon } from 'soapbox/components/ui';
|
||||||
import Search from 'soapbox/features/compose/components/search';
|
import Search from 'soapbox/features/compose/components/search';
|
||||||
import { useAccount, useSoapboxConfig, useSettings } from 'soapbox/hooks';
|
import { useOwnAccount, useSoapboxConfig, useSettings } from 'soapbox/hooks';
|
||||||
|
|
||||||
import { openSidebar } from '../../../actions/sidebar';
|
import { openSidebar } from '../../../actions/sidebar';
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ const Navbar = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const node = React.useRef(null);
|
const node = React.useRef(null);
|
||||||
|
|
||||||
const account = useAccount();
|
const account = useOwnAccount();
|
||||||
const settings = useSettings();
|
const settings = useSettings();
|
||||||
const soapboxConfig = useSoapboxConfig();
|
const soapboxConfig = useSoapboxConfig();
|
||||||
const singleUserMode = soapboxConfig.get('singleUserMode');
|
const singleUserMode = soapboxConfig.get('singleUserMode');
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
export { useAccount } from './useAccount';
|
|
||||||
export { useAppSelector } from './useAppSelector';
|
export { useAppSelector } from './useAppSelector';
|
||||||
export { useOnScreen } from './useOnScreen';
|
export { useOnScreen } from './useOnScreen';
|
||||||
|
export { useOwnAccount } from './useOwnAccount';
|
||||||
export { useSettings } from './useSettings';
|
export { useSettings } from './useSettings';
|
||||||
export { useSoapboxConfig } from './useSoapboxConfig';
|
export { useSoapboxConfig } from './useSoapboxConfig';
|
||||||
|
|
|
@ -7,7 +7,7 @@ import type Account from 'soapbox/types/entities/account';
|
||||||
// FIXME: getAccount() has the wrong type??
|
// FIXME: getAccount() has the wrong type??
|
||||||
const getAccount: (state: any, accountId: any) => any = makeGetAccount();
|
const getAccount: (state: any, accountId: any) => any = makeGetAccount();
|
||||||
|
|
||||||
/** Get an account from the store (by default, your own account) */
|
/** Get the logged-in account from the store, if any */
|
||||||
export const useAccount = (accountId?: string): Account => {
|
export const useOwnAccount = (): Account | null => {
|
||||||
return useAppSelector((state) => getAccount(state, accountId || state.me));
|
return useAppSelector((state) => getAccount(state, state.me));
|
||||||
};
|
};
|
Loading…
Reference in a new issue