ActionButton: add jsdoc comments
This commit is contained in:
parent
9e09823f80
commit
6fa6e5b3b4
1 changed files with 12 additions and 2 deletions
|
@ -31,11 +31,19 @@ const messages = defineMessages({
|
||||||
});
|
});
|
||||||
|
|
||||||
interface IActionButton {
|
interface IActionButton {
|
||||||
|
/** Target account for the action. */
|
||||||
account: AccountEntity
|
account: AccountEntity
|
||||||
|
/** Type of action to prioritize, eg on Blocks and Mutes pages. */
|
||||||
actionType?: 'muting' | 'blocking'
|
actionType?: 'muting' | 'blocking'
|
||||||
|
/** Displays shorter text on the "Awaiting approval" button. */
|
||||||
small?: boolean
|
small?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Circumstantial action button (usually "Follow") to display on accounts.
|
||||||
|
* May say "Unblock" or something else, depending on the relationship and
|
||||||
|
* `actionType` prop.
|
||||||
|
*/
|
||||||
const ActionButton: React.FC<IActionButton> = ({ account, actionType, small }) => {
|
const ActionButton: React.FC<IActionButton> = ({ account, actionType, small }) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
|
@ -75,6 +83,7 @@ const ActionButton: React.FC<IActionButton> = ({ account, actionType, small }) =
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Handles actionType='muting' */
|
||||||
const mutingAction = () => {
|
const mutingAction = () => {
|
||||||
const isMuted = account.getIn(['relationship', 'muting']);
|
const isMuted = account.getIn(['relationship', 'muting']);
|
||||||
const messageKey = isMuted ? messages.unmute : messages.mute;
|
const messageKey = isMuted ? messages.unmute : messages.mute;
|
||||||
|
@ -90,6 +99,7 @@ const ActionButton: React.FC<IActionButton> = ({ account, actionType, small }) =
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Handles actionType='blocking' */
|
||||||
const blockingAction = () => {
|
const blockingAction = () => {
|
||||||
const isBlocked = account.getIn(['relationship', 'blocking']);
|
const isBlocked = account.getIn(['relationship', 'blocking']);
|
||||||
const messageKey = isBlocked ? messages.unblock : messages.block;
|
const messageKey = isBlocked ? messages.unblock : messages.block;
|
||||||
|
@ -106,7 +116,7 @@ const ActionButton: React.FC<IActionButton> = ({ account, actionType, small }) =
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Render a remote follow button, depending on features. */
|
/** Render a remote follow button, depending on features. */
|
||||||
const renderRemoteFollow = (): JSX.Element | null => {
|
const renderRemoteFollow = () => {
|
||||||
// Remote follow through the API.
|
// Remote follow through the API.
|
||||||
if (features.remoteInteractionsAPI) {
|
if (features.remoteInteractionsAPI) {
|
||||||
return (
|
return (
|
||||||
|
@ -131,7 +141,7 @@ const ActionButton: React.FC<IActionButton> = ({ account, actionType, small }) =
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Render remote follow if federating, otherwise hide the button. */
|
/** Render remote follow if federating, otherwise hide the button. */
|
||||||
const renderLoggedOut = (): JSX.Element | null => {
|
const renderLoggedOut = () => {
|
||||||
if (features.federating) {
|
if (features.federating) {
|
||||||
return renderRemoteFollow();
|
return renderRemoteFollow();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue