Make useOwnAccount return an object
This commit is contained in:
parent
a8459ced75
commit
d4eaf1e27a
53 changed files with 62 additions and 64 deletions
|
@ -6,7 +6,7 @@ import type { Group } from 'soapbox/schemas';
|
||||||
|
|
||||||
function useCancelMembershipRequest(group: Group) {
|
function useCancelMembershipRequest(group: Group) {
|
||||||
const api = useApi();
|
const api = useApi();
|
||||||
const me = useOwnAccount();
|
const { account: me } = useOwnAccount();
|
||||||
|
|
||||||
const { createEntity, isSubmitting } = useCreateEntity(
|
const { createEntity, isSubmitting } = useCreateEntity(
|
||||||
[Entities.GROUP_RELATIONSHIPS],
|
[Entities.GROUP_RELATIONSHIPS],
|
||||||
|
|
|
@ -24,7 +24,7 @@ const SidebarNavigation = () => {
|
||||||
|
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const settings = useSettings();
|
const settings = useSettings();
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const groupsPath = useGroupsPath();
|
const groupsPath = useGroupsPath();
|
||||||
|
|
||||||
const notificationCount = useAppSelector((state) => state.notifications.unread);
|
const notificationCount = useAppSelector((state) => state.notifications.unread);
|
||||||
|
|
|
@ -123,7 +123,7 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
|
||||||
|
|
||||||
const { allowedEmoji } = soapboxConfig;
|
const { allowedEmoji } = soapboxConfig;
|
||||||
|
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const isStaff = account ? account.staff : false;
|
const isStaff = account ? account.staff : false;
|
||||||
const isAdmin = account ? account.admin : false;
|
const isAdmin = account ? account.admin : false;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ interface IStatusReactionWrapper {
|
||||||
/** Provides emoji reaction functionality to the underlying button component */
|
/** Provides emoji reaction functionality to the underlying button component */
|
||||||
const StatusReactionWrapper: React.FC<IStatusReactionWrapper> = ({ statusId, children }): JSX.Element | null => {
|
const StatusReactionWrapper: React.FC<IStatusReactionWrapper> = ({ statusId, children }): JSX.Element | null => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const ownAccount = useOwnAccount();
|
const { account: ownAccount } = useOwnAccount();
|
||||||
const status = useAppSelector(state => state.statuses.get(statusId));
|
const status = useAppSelector(state => state.statuses.get(statusId));
|
||||||
const soapboxConfig = useSoapboxConfig();
|
const soapboxConfig = useSoapboxConfig();
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ interface ISensitiveContentOverlay {
|
||||||
const SensitiveContentOverlay = React.forwardRef<HTMLDivElement, ISensitiveContentOverlay>((props, ref) => {
|
const SensitiveContentOverlay = React.forwardRef<HTMLDivElement, ISensitiveContentOverlay>((props, ref) => {
|
||||||
const { onToggleVisibility, status } = props;
|
const { onToggleVisibility, status } = props;
|
||||||
|
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const settings = useSettings();
|
const settings = useSettings();
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { useStatContext } from 'soapbox/contexts/stat-context';
|
||||||
import { useAppSelector, useFeatures, useGroupsPath, useOwnAccount } from 'soapbox/hooks';
|
import { useAppSelector, useFeatures, useGroupsPath, useOwnAccount } from 'soapbox/hooks';
|
||||||
|
|
||||||
const ThumbNavigation: React.FC = (): JSX.Element => {
|
const ThumbNavigation: React.FC = (): JSX.Element => {
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const groupsPath = useGroupsPath();
|
const groupsPath = useGroupsPath();
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ const SoapboxMount = () => {
|
||||||
|
|
||||||
const me = useAppSelector(state => state.me);
|
const me = useAppSelector(state => state.me);
|
||||||
const instance = useInstance();
|
const instance = useInstance();
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const soapboxConfig = useSoapboxConfig();
|
const soapboxConfig = useSoapboxConfig();
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const { pepeEnabled } = useRegistrationStatus();
|
const { pepeEnabled } = useRegistrationStatus();
|
||||||
|
@ -217,7 +217,7 @@ const SoapboxLoad: React.FC<ISoapboxLoad> = ({ children }) => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const me = useAppSelector(state => state.me);
|
const me = useAppSelector(state => state.me);
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const swUpdating = useAppSelector(state => state.meta.swUpdating);
|
const swUpdating = useAppSelector(state => state.meta.swUpdating);
|
||||||
const { locale } = useLocale();
|
const { locale } = useLocale();
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ const ChatProvider: React.FC<IChatProvider> = ({ children }) => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const settings = useSettings();
|
const settings = useSettings();
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
|
|
||||||
const path = history.location.pathname;
|
const path = history.location.pathname;
|
||||||
const isUsingMainChatPage = Boolean(path.match(/^\/chats/));
|
const isUsingMainChatPage = Boolean(path.match(/^\/chats/));
|
||||||
|
|
|
@ -87,7 +87,7 @@ const Header: React.FC<IHeader> = ({ account }) => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const ownAccount = useOwnAccount();
|
const { account: ownAccount } = useOwnAccount();
|
||||||
const { follow } = useFollow();
|
const { follow } = useFollow();
|
||||||
|
|
||||||
const { software } = useAppSelector((state) => parseVersion(state.instance.version));
|
const { software } = useAppSelector((state) => parseVersion(state.instance.version));
|
||||||
|
|
|
@ -16,7 +16,7 @@ const messages = defineMessages({
|
||||||
|
|
||||||
const Admin: React.FC = () => {
|
const Admin: React.FC = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
|
|
||||||
if (!account) return null;
|
if (!account) return null;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ const Dashboard: React.FC = () => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const instance = useInstance();
|
const instance = useInstance();
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
|
|
||||||
const handleSubscribersClick: React.MouseEventHandler = e => {
|
const handleSubscribersClick: React.MouseEventHandler = e => {
|
||||||
dispatch(getSubscribersCsv()).then(({ data }) => {
|
dispatch(getSubscribersCsv()).then(({ data }) => {
|
||||||
|
|
|
@ -23,7 +23,7 @@ const Aliases = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
|
|
||||||
const aliases = useAppSelector((state) => {
|
const aliases = useAppSelector((state) => {
|
||||||
if (features.accountMoving) {
|
if (features.accountMoving) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ const AuthLayout = () => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const { search } = useLocation();
|
const { search } = useLocation();
|
||||||
|
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const instance = useInstance();
|
const instance = useInstance();
|
||||||
const { isOpen } = useRegistrationStatus();
|
const { isOpen } = useRegistrationStatus();
|
||||||
const isLoginPage = history.location.pathname === '/login';
|
const isLoginPage = history.location.pathname === '/login';
|
||||||
|
|
|
@ -69,7 +69,7 @@ interface IChatMessageList {
|
||||||
/** Scrollable list of chat messages. */
|
/** Scrollable list of chat messages. */
|
||||||
const ChatMessageList: React.FC<IChatMessageList> = ({ chat }) => {
|
const ChatMessageList: React.FC<IChatMessageList> = ({ chat }) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
|
|
||||||
const myLastReadMessageDateString = chat.latest_read_message_by_account?.find((latest) => latest.id === account?.id)?.date;
|
const myLastReadMessageDateString = chat.latest_read_message_by_account?.find((latest) => latest.id === account?.id)?.date;
|
||||||
const myLastReadMessageTimestamp = myLastReadMessageDateString ? new Date(myLastReadMessageDateString) : null;
|
const myLastReadMessageTimestamp = myLastReadMessageDateString ? new Date(myLastReadMessageDateString) : null;
|
||||||
|
|
|
@ -16,7 +16,7 @@ interface IChatPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
const ChatPage: React.FC<IChatPage> = ({ chatId }) => {
|
const ChatPage: React.FC<IChatPage> = ({ chatId }) => {
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
const isOnboarded = account?.source?.chats_onboarded ?? true;
|
const isOnboarded = account?.source?.chats_onboarded ?? true;
|
||||||
|
|
|
@ -24,7 +24,7 @@ const messages = defineMessages({
|
||||||
});
|
});
|
||||||
|
|
||||||
const ChatPageSettings = () => {
|
const ChatPageSettings = () => {
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
|
@ -20,7 +20,7 @@ const messages = defineMessages({
|
||||||
});
|
});
|
||||||
|
|
||||||
const Welcome = () => {
|
const Welcome = () => {
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const updateCredentials = useUpdateCredentials();
|
const updateCredentials = useUpdateCredentials();
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { useOwnAccount } from 'soapbox/hooks';
|
||||||
import ChatPane from '../chat-pane/chat-pane';
|
import ChatPane from '../chat-pane/chat-pane';
|
||||||
|
|
||||||
const ChatWidget = () => {
|
const ChatWidget = () => {
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
const path = history.location.pathname;
|
const path = history.location.pathname;
|
||||||
|
|
|
@ -25,7 +25,7 @@ type Params = typeof BLANK_PARAMS;
|
||||||
const CreateApp: React.FC = () => {
|
const CreateApp: React.FC = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
|
|
||||||
const [app, setApp] = useState<Record<string, any> | null>(null);
|
const [app, setApp] = useState<Record<string, any> | null>(null);
|
||||||
const [token, setToken] = useState<string | null>(null);
|
const [token, setToken] = useState<string | null>(null);
|
||||||
|
|
|
@ -177,7 +177,7 @@ const EditProfile: React.FC = () => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const instance = useInstance();
|
const instance = useInstance();
|
||||||
|
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const maxFields = instance.pleroma.getIn(['metadata', 'fields_limits', 'max_fields'], 4) as number;
|
const maxFields = instance.pleroma.getIn(['metadata', 'fields_limits', 'max_fields'], 4) as number;
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ const EventHeader: React.FC<IEventHeader> = ({ status }) => {
|
||||||
|
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const settings = useSettings();
|
const settings = useSettings();
|
||||||
const ownAccount = useOwnAccount();
|
const { account: ownAccount } = useOwnAccount();
|
||||||
const isStaff = ownAccount ? ownAccount.staff : false;
|
const isStaff = ownAccount ? ownAccount.staff : false;
|
||||||
const isAdmin = ownAccount ? ownAccount.admin : false;
|
const isAdmin = ownAccount ? ownAccount.admin : false;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ const Favourites: React.FC<IFavourites> = ({ params }) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const ownAccount = useOwnAccount();
|
const { account: ownAccount } = useOwnAccount();
|
||||||
const { account } = useAccount(params?.username, { withRelationship: true });
|
const { account } = useAccount(params?.username, { withRelationship: true });
|
||||||
|
|
||||||
const username = params?.username || '';
|
const username = params?.username || '';
|
||||||
|
|
|
@ -31,7 +31,7 @@ const Followers: React.FC<IFollowers> = (props) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const ownAccount = useOwnAccount();
|
const { account: ownAccount } = useOwnAccount();
|
||||||
|
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ const Following: React.FC<IFollowing> = (props) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const ownAccount = useOwnAccount();
|
const { account: ownAccount } = useOwnAccount();
|
||||||
|
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ const messages = defineMessages({
|
||||||
const GroupActionButton = ({ group }: IGroupActionButton) => {
|
const GroupActionButton = ({ group }: IGroupActionButton) => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
|
|
||||||
const joinGroup = useJoinGroup(group);
|
const joinGroup = useJoinGroup(group);
|
||||||
const leaveGroup = useLeaveGroup(group);
|
const leaveGroup = useLeaveGroup(group);
|
||||||
|
|
|
@ -27,7 +27,7 @@ interface IGroupActionButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
const GroupOptionsButton = ({ group }: IGroupActionButton) => {
|
const GroupOptionsButton = ({ group }: IGroupActionButton) => {
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const leaveGroup = useLeaveGroup(group);
|
const leaveGroup = useLeaveGroup(group);
|
||||||
|
|
|
@ -24,7 +24,7 @@ const getStatusIds = makeGetStatusIds();
|
||||||
|
|
||||||
const GroupTimeline: React.FC<IGroupTimeline> = (props) => {
|
const GroupTimeline: React.FC<IGroupTimeline> = (props) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const composer = useRef<HTMLDivElement>(null);
|
const composer = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ interface Props {
|
||||||
export default (props: Props) => {
|
export default (props: Props) => {
|
||||||
const { onSelect } = props;
|
const { onSelect } = props;
|
||||||
|
|
||||||
const me = useOwnAccount();
|
const { account: me } = useOwnAccount();
|
||||||
|
|
||||||
const [recentSearches, setRecentSearches] = useState<string[]>(groupSearchHistory.get(me?.id as string) || []);
|
const [recentSearches, setRecentSearches] = useState<string[]>(groupSearchHistory.get(me?.id as string) || []);
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ interface Props {
|
||||||
export default (props: Props) => {
|
export default (props: Props) => {
|
||||||
const { onSelect, searchValue } = props;
|
const { onSelect, searchValue } = props;
|
||||||
|
|
||||||
const me = useOwnAccount();
|
const { account: me } = useOwnAccount();
|
||||||
const debounce = useDebounce;
|
const debounce = useDebounce;
|
||||||
|
|
||||||
const debouncedValue = debounce(searchValue as string, 300);
|
const debouncedValue = debounce(searchValue as string, 300);
|
||||||
|
|
|
@ -17,7 +17,7 @@ const messages = defineMessages({
|
||||||
|
|
||||||
const AvatarSelectionStep = ({ onNext }: { onNext: () => void }) => {
|
const AvatarSelectionStep = ({ onNext }: { onNext: () => void }) => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
|
|
||||||
const fileInput = React.useRef<HTMLInputElement>(null);
|
const fileInput = React.useRef<HTMLInputElement>(null);
|
||||||
const [selectedFile, setSelectedFile] = React.useState<string | null>();
|
const [selectedFile, setSelectedFile] = React.useState<string | null>();
|
||||||
|
|
|
@ -17,7 +17,7 @@ const BioStep = ({ onNext }: { onNext: () => void }) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const [value, setValue] = React.useState<string>(account?.source?.note ?? '');
|
const [value, setValue] = React.useState<string>(account?.source?.note ?? '');
|
||||||
const [isSubmitting, setSubmitting] = React.useState<boolean>(false);
|
const [isSubmitting, setSubmitting] = React.useState<boolean>(false);
|
||||||
const [errors, setErrors] = React.useState<string[]>([]);
|
const [errors, setErrors] = React.useState<string[]>([]);
|
||||||
|
|
|
@ -20,7 +20,7 @@ const messages = defineMessages({
|
||||||
const CoverPhotoSelectionStep = ({ onNext }: { onNext: () => void }) => {
|
const CoverPhotoSelectionStep = ({ onNext }: { onNext: () => void }) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
|
|
||||||
const fileInput = React.useRef<HTMLInputElement>(null);
|
const fileInput = React.useRef<HTMLInputElement>(null);
|
||||||
const [selectedFile, setSelectedFile] = React.useState<string | null>();
|
const [selectedFile, setSelectedFile] = React.useState<string | null>();
|
||||||
|
|
|
@ -17,7 +17,7 @@ const DisplayNameStep = ({ onNext }: { onNext: () => void }) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const [value, setValue] = React.useState<string>(account?.display_name || '');
|
const [value, setValue] = React.useState<string>(account?.display_name || '');
|
||||||
const [isSubmitting, setSubmitting] = React.useState<boolean>(false);
|
const [isSubmitting, setSubmitting] = React.useState<boolean>(false);
|
||||||
const [errors, setErrors] = React.useState<string[]>([]);
|
const [errors, setErrors] = React.useState<string[]>([]);
|
||||||
|
|
|
@ -5,10 +5,8 @@ import Account from 'soapbox/components/account';
|
||||||
import { Button, Card, CardBody, Icon, Stack, Text } from 'soapbox/components/ui';
|
import { Button, Card, CardBody, Icon, Stack, Text } from 'soapbox/components/ui';
|
||||||
import { useInstance, useOwnAccount } from 'soapbox/hooks';
|
import { useInstance, useOwnAccount } from 'soapbox/hooks';
|
||||||
|
|
||||||
import type { Account as AccountEntity } from 'soapbox/types/entities';
|
|
||||||
|
|
||||||
const FediverseStep = ({ onNext }: { onNext: () => void }) => {
|
const FediverseStep = ({ onNext }: { onNext: () => void }) => {
|
||||||
const account = useOwnAccount() as AccountEntity;
|
const { account } = useOwnAccount();
|
||||||
const instance = useInstance();
|
const instance = useInstance();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -49,9 +47,11 @@ const FediverseStep = ({ onNext }: { onNext: () => void }) => {
|
||||||
</Stack>
|
</Stack>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{account && (
|
||||||
<div className='rounded-lg bg-primary-50 p-4 text-center dark:bg-gray-800'>
|
<div className='rounded-lg bg-primary-50 p-4 text-center dark:bg-gray-800'>
|
||||||
<Account account={account} />
|
<Account account={account} />
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<Text theme='muted'>
|
<Text theme='muted'>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
|
|
|
@ -29,7 +29,7 @@ const Header = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
|
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const soapboxConfig = useSoapboxConfig();
|
const soapboxConfig = useSoapboxConfig();
|
||||||
const { isOpen } = useRegistrationStatus();
|
const { isOpen } = useRegistrationStatus();
|
||||||
const { links } = soapboxConfig;
|
const { links } = soapboxConfig;
|
||||||
|
|
|
@ -11,7 +11,7 @@ const messages = defineMessages({
|
||||||
});
|
});
|
||||||
|
|
||||||
const MessagesSettings = () => {
|
const MessagesSettings = () => {
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const updateCredentials = useUpdateCredentials();
|
const updateCredentials = useUpdateCredentials();
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ const Settings = () => {
|
||||||
|
|
||||||
const mfa = useAppSelector((state) => state.security.get('mfa'));
|
const mfa = useAppSelector((state) => state.security.get('mfa'));
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
|
|
||||||
const navigateToChangeEmail = () => history.push('/settings/email');
|
const navigateToChangeEmail = () => history.push('/settings/email');
|
||||||
const navigateToChangePassword = () => history.push('/settings/password');
|
const navigateToChangePassword = () => history.push('/settings/password');
|
||||||
|
|
|
@ -97,7 +97,7 @@ const Thread = (props: IThread) => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const me = useOwnAccount();
|
const { account: me } = useOwnAccount();
|
||||||
const settings = useSettings();
|
const settings = useSettings();
|
||||||
|
|
||||||
const displayMedia = settings.get('displayMedia') as DisplayMedia;
|
const displayMedia = settings.get('displayMedia') as DisplayMedia;
|
||||||
|
|
|
@ -26,7 +26,7 @@ const InstanceModerationPanel: React.FC<IInstanceModerationPanel> = ({ host }) =
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const remoteInstance = useAppSelector(state => getRemoteInstance(state, host));
|
const remoteInstance = useAppSelector(state => getRemoteInstance(state, host));
|
||||||
|
|
||||||
const handleEditFederation = () => {
|
const handleEditFederation = () => {
|
||||||
|
|
|
@ -25,7 +25,7 @@ const FooterLink: React.FC<IFooterLink> = ({ children, className, ...rest }): JS
|
||||||
};
|
};
|
||||||
|
|
||||||
const LinkFooter: React.FC = (): JSX.Element => {
|
const LinkFooter: React.FC = (): JSX.Element => {
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const soapboxConfig = useSoapboxConfig();
|
const soapboxConfig = useSoapboxConfig();
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ const AccountModerationModal: React.FC<IAccountModerationModal> = ({ onClose, ac
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const ownAccount = useOwnAccount();
|
const { account: ownAccount } = useOwnAccount();
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const { account } = useAccount(accountId);
|
const { account } = useAccount(accountId);
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ const Navbar = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const { isOpen } = useRegistrationStatus();
|
const { isOpen } = useRegistrationStatus();
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const node = useRef(null);
|
const node = useRef(null);
|
||||||
|
|
||||||
const [isLoading, setLoading] = useState<boolean>(false);
|
const [isLoading, setLoading] = useState<boolean>(false);
|
||||||
|
|
|
@ -399,7 +399,7 @@ const UI: React.FC<IUI> = ({ children }) => {
|
||||||
const hotkeys = useRef<HTMLDivElement | null>(null);
|
const hotkeys = useRef<HTMLDivElement | null>(null);
|
||||||
|
|
||||||
const me = useAppSelector(state => state.me);
|
const me = useAppSelector(state => state.me);
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const vapidKey = useAppSelector(state => getVapidKey(state));
|
const vapidKey = useAppSelector(state => getVapidKey(state));
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ const WrappedRoute: React.FC<IWrappedRoute> = ({
|
||||||
}) => {
|
}) => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const settings = useSettings();
|
const settings = useSettings();
|
||||||
|
|
||||||
const renderComponent = ({ match }: RouteComponentProps) => {
|
const renderComponent = ({ match }: RouteComponentProps) => {
|
||||||
|
|
|
@ -13,7 +13,7 @@ const WaitlistPage = () => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const instance = useInstance();
|
const instance = useInstance();
|
||||||
|
|
||||||
const me = useOwnAccount();
|
const { account: me } = useOwnAccount();
|
||||||
const isSmsVerified = me?.source?.sms_verified ?? true;
|
const isSmsVerified = me?.source?.sms_verified ?? true;
|
||||||
|
|
||||||
const onClickLogOut: React.MouseEventHandler = (event) => {
|
const onClickLogOut: React.MouseEventHandler = (event) => {
|
||||||
|
|
|
@ -3,19 +3,17 @@ import { useCallback } from 'react';
|
||||||
import { useAppSelector } from 'soapbox/hooks';
|
import { useAppSelector } from 'soapbox/hooks';
|
||||||
import { makeGetAccount } from 'soapbox/selectors';
|
import { makeGetAccount } from 'soapbox/selectors';
|
||||||
|
|
||||||
import type { Account } from 'soapbox/types/entities';
|
|
||||||
|
|
||||||
/** Get the logged-in account from the store, if any. */
|
/** Get the logged-in account from the store, if any. */
|
||||||
export const useOwnAccount = (): Account | null => {
|
export const useOwnAccount = () => {
|
||||||
const getAccount = useCallback(makeGetAccount(), []);
|
const getAccount = useCallback(makeGetAccount(), []);
|
||||||
|
|
||||||
return useAppSelector((state) => {
|
const account = useAppSelector((state) => {
|
||||||
const { me } = state;
|
const { me } = state;
|
||||||
|
|
||||||
if (typeof me === 'string') {
|
if (typeof me === 'string') {
|
||||||
return getAccount(state, me);
|
return getAccount(state, me);
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return { account: account || undefined };
|
||||||
};
|
};
|
||||||
|
|
|
@ -96,7 +96,7 @@ const GroupPage: React.FC<IGroupPage> = ({ params, children }) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const match = useRouteMatch();
|
const match = useRouteMatch();
|
||||||
const me = useOwnAccount();
|
const { account: me } = useOwnAccount();
|
||||||
|
|
||||||
const id = params?.groupId || '';
|
const id = params?.groupId || '';
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ const HomePage: React.FC<IHomePage> = ({ children }) => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const me = useAppSelector(state => state.me);
|
const me = useAppSelector(state => state.me);
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const soapboxConfig = useSoapboxConfig();
|
const soapboxConfig = useSoapboxConfig();
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ interface IRemoteInstancePage {
|
||||||
const RemoteInstancePage: React.FC<IRemoteInstancePage> = ({ children, params }) => {
|
const RemoteInstancePage: React.FC<IRemoteInstancePage> = ({ children, params }) => {
|
||||||
const host = params?.instance;
|
const host = params?.instance;
|
||||||
|
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const disclosed = useAppSelector(federationRestrictionsDisclosed);
|
const disclosed = useAppSelector(federationRestrictionsDisclosed);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -35,7 +35,7 @@ type UpdateCredentialsData = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const useUpdateCredentials = () => {
|
const useUpdateCredentials = () => {
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const api = useApi();
|
const api = useApi();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,7 @@ const useChat = (chatId?: string) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const useChatActions = (chatId: string) => {
|
const useChatActions = (chatId: string) => {
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const api = useApi();
|
const api = useApi();
|
||||||
// const dispatch = useAppDispatch();
|
// const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ const useGroupsApi = () => {
|
||||||
|
|
||||||
const usePendingGroups = () => {
|
const usePendingGroups = () => {
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const { fetchGroups } = useGroupsApi();
|
const { fetchGroups } = useGroupsApi();
|
||||||
|
|
||||||
const getGroups = async (pageParam?: any): Promise<PaginatedResult<Group>> => {
|
const getGroups = async (pageParam?: any): Promise<PaginatedResult<Group>> => {
|
||||||
|
|
|
@ -14,7 +14,7 @@ const PolicyKeys = {
|
||||||
|
|
||||||
function usePendingPolicy() {
|
function usePendingPolicy() {
|
||||||
const api = useApi();
|
const api = useApi();
|
||||||
const account = useOwnAccount();
|
const { account } = useOwnAccount();
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
|
|
||||||
const getPolicy = async() => {
|
const getPolicy = async() => {
|
||||||
|
|
Loading…
Reference in a new issue