ActionButton: put remote follow behind feature detection

This commit is contained in:
Alex Gleason 2022-05-14 11:21:12 -05:00
parent 3b0530073e
commit 3d898957e3
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 35 additions and 12 deletions

View file

@ -105,10 +105,9 @@ const ActionButton = ({ account, actionType, small }: iActionButton) => {
);
};
const empty = <></>;
if (!me) {
// Remote follow
/** Render a remote follow button, depending on features. */
const renderRemoteFollow = (): JSX.Element | null => {
// Remote follow through the API.
if (features.remoteInteractionsAPI) {
return (
<Button
@ -117,18 +116,36 @@ const ActionButton = ({ account, actionType, small }: iActionButton) => {
text={intl.formatMessage(messages.follow)}
/>
);
// Pleroma's classic remote follow form.
} else if (features.pleromaRemoteFollow) {
return (
<form method='POST' action='/main/ostatus'>
<input type='hidden' name='nickname' value={account.acct} />
<input type='hidden' name='profile' value='' />
<Button text={intl.formatMessage(messages.remote_follow)} type='submit' />
</form>
);
}
return (
<form method='POST' action='/main/ostatus'>
<input type='hidden' name='nickname' value={account.get('acct')} />
<input type='hidden' name='profile' value='' />
<Button text={intl.formatMessage(messages.remote_follow)} type='submit' />
</form>
);
return null;
};
/** Render remote follow if federating, otherwise hide the button. */
const renderLoggedOut = (): JSX.Element | null => {
if (features.federating) {
return renderRemoteFollow();
}
return null;
};
const empty = <></>;
if (!me) {
return renderLoggedOut();
}
if (me !== account.get('id')) {
if (me !== account.id) {
const isFollowing = account.getIn(['relationship', 'following']);
const blockedBy = account.getIn(['relationship', 'blocked_by']) as boolean;

View file

@ -356,6 +356,12 @@ const getInstanceFeatures = (instance: Instance) => {
*/
paginatedContext: v.software === TRUTHSOCIAL,
/**
* Displays a form to follow a user when logged out.
* @see POST /main/ostatus
*/
pleromaRemoteFollow: v.software === PLEROMA,
/**
* Can add polls to statuses.
* @see POST /api/v1/statuses