Hooks: get rid of useAccount, create useOwnAccount

virtualized-window
Alex Gleason 2022-03-23 21:05:55 -05:00
rodzic 2da31341c4
commit be690255cb
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
3 zmienionych plików z 6 dodań i 6 usunięć

Wyświetl plik

@ -6,7 +6,7 @@ import { Link } from 'react-router-dom';
import { Avatar, Button, Icon } from 'soapbox/components/ui';
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';
@ -16,7 +16,7 @@ const Navbar = () => {
const dispatch = useDispatch();
const node = React.useRef(null);
const account = useAccount();
const account = useOwnAccount();
const settings = useSettings();
const soapboxConfig = useSoapboxConfig();
const singleUserMode = soapboxConfig.get('singleUserMode');

Wyświetl plik

@ -1,5 +1,5 @@
export { useAccount } from './useAccount';
export { useAppSelector } from './useAppSelector';
export { useOnScreen } from './useOnScreen';
export { useOwnAccount } from './useOwnAccount';
export { useSettings } from './useSettings';
export { useSoapboxConfig } from './useSoapboxConfig';

Wyświetl plik

@ -7,7 +7,7 @@ import type Account from 'soapbox/types/entities/account';
// FIXME: getAccount() has the wrong type??
const getAccount: (state: any, accountId: any) => any = makeGetAccount();
/** Get an account from the store (by default, your own account) */
export const useAccount = (accountId?: string): Account => {
return useAppSelector((state) => getAccount(state, accountId || state.me));
/** Get the logged-in account from the store, if any */
export const useOwnAccount = (): Account | null => {
return useAppSelector((state) => getAccount(state, state.me));
};