From 6fa6e5b3b4d0c1da230f397d3798aa13df891f2f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 14 May 2022 11:48:57 -0500 Subject: [PATCH] ActionButton: add jsdoc comments --- .../features/ui/components/action-button.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/soapbox/features/ui/components/action-button.tsx b/app/soapbox/features/ui/components/action-button.tsx index 7d59674179..acf06e2447 100644 --- a/app/soapbox/features/ui/components/action-button.tsx +++ b/app/soapbox/features/ui/components/action-button.tsx @@ -31,11 +31,19 @@ const messages = defineMessages({ }); interface IActionButton { + /** Target account for the action. */ account: AccountEntity + /** Type of action to prioritize, eg on Blocks and Mutes pages. */ actionType?: 'muting' | 'blocking' + /** Displays shorter text on the "Awaiting approval" button. */ 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 = ({ account, actionType, small }) => { const dispatch = useDispatch(); const features = useFeatures(); @@ -75,6 +83,7 @@ const ActionButton: React.FC = ({ account, actionType, small }) = })); }; + /** Handles actionType='muting' */ const mutingAction = () => { const isMuted = account.getIn(['relationship', 'muting']); const messageKey = isMuted ? messages.unmute : messages.mute; @@ -90,6 +99,7 @@ const ActionButton: React.FC = ({ account, actionType, small }) = ); }; + /** Handles actionType='blocking' */ const blockingAction = () => { const isBlocked = account.getIn(['relationship', 'blocking']); const messageKey = isBlocked ? messages.unblock : messages.block; @@ -106,7 +116,7 @@ const ActionButton: React.FC = ({ account, actionType, small }) = }; /** Render a remote follow button, depending on features. */ - const renderRemoteFollow = (): JSX.Element | null => { + const renderRemoteFollow = () => { // Remote follow through the API. if (features.remoteInteractionsAPI) { return ( @@ -131,7 +141,7 @@ const ActionButton: React.FC = ({ account, actionType, small }) = }; /** Render remote follow if federating, otherwise hide the button. */ - const renderLoggedOut = (): JSX.Element | null => { + const renderLoggedOut = () => { if (features.federating) { return renderRemoteFollow(); }