From 850e8e5f3c9a82bc4326bc92e56c2d9212b72b92 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 3 Nov 2022 16:05:39 +0100 Subject: [PATCH] [Glitch] Fix being unable to withdraw follow request when confirmation modal is disabled (#19687) Port b0d4b7d956d4e800ebd3e4339729557e0eb8dfc2 to glitch-soc Signed-off-by: Claire --- .../containers/header_container.js | 2 ++ .../directory/components/account_card.js | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/javascript/flavours/glitch/features/account_timeline/containers/header_container.js b/app/javascript/flavours/glitch/features/account_timeline/containers/header_container.js index e6d8bb3bc8..a65463243c 100644 --- a/app/javascript/flavours/glitch/features/account_timeline/containers/header_container.js +++ b/app/javascript/flavours/glitch/features/account_timeline/containers/header_container.js @@ -61,6 +61,8 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ confirm: intl.formatMessage(messages.cancelFollowRequestConfirm), onConfirm: () => dispatch(unfollowAccount(account.get('id'))), })); + } else { + dispatch(unfollowAccount(account.get('id'))); } } else { dispatch(followAccount(account.get('id'))); diff --git a/app/javascript/flavours/glitch/features/directory/components/account_card.js b/app/javascript/flavours/glitch/features/directory/components/account_card.js index 8c344c7931..ccc3dd3d2e 100644 --- a/app/javascript/flavours/glitch/features/directory/components/account_card.js +++ b/app/javascript/flavours/glitch/features/directory/components/account_card.js @@ -25,6 +25,7 @@ const messages = defineMessages({ unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' }, follow: { id: 'account.follow', defaultMessage: 'Follow' }, cancel_follow_request: { id: 'account.cancel_follow_request', defaultMessage: 'Withdraw follow request' }, + cancelFollowRequestConfirm: { id: 'confirmations.cancel_follow_request.confirm', defaultMessage: 'Withdraw request' }, requested: { id: 'account.requested', defaultMessage: 'Awaiting approval. Click to cancel follow request' }, unblock: { id: 'account.unblock_short', defaultMessage: 'Unblock' }, unmute: { id: 'account.unmute_short', defaultMessage: 'Unmute' }, @@ -45,10 +46,7 @@ const makeMapStateToProps = () => { const mapDispatchToProps = (dispatch, { intl }) => ({ onFollow(account) { - if ( - account.getIn(['relationship', 'following']) || - account.getIn(['relationship', 'requested']) - ) { + if (account.getIn(['relationship', 'following'])) { if (unfollowModal) { dispatch( openModal('CONFIRM', { @@ -66,6 +64,16 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ } else { dispatch(unfollowAccount(account.get('id'))); } + } else if (account.getIn(['relationship', 'requested'])) { + if (unfollowModal) { + dispatch(openModal('CONFIRM', { + message: @{account.get('acct')} }} />, + confirm: intl.formatMessage(messages.cancelFollowRequestConfirm), + onConfirm: () => dispatch(unfollowAccount(account.get('id'))), + })); + } else { + dispatch(unfollowAccount(account.get('id'))); + } } else { dispatch(followAccount(account.get('id'))); }