Make useOwnAccount return an object

This commit is contained in:
Alex Gleason
2023-06-25 12:35:09 -05:00
parent a8459ced75
commit d4eaf1e27a
53 changed files with 62 additions and 64 deletions

View File

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