Update confirmation dialogs for follow button actions "unfollow", "unblock", and "withdraw request" (#36289)

This commit is contained in:
diondiondion 2025-09-30 16:55:25 +02:00 committed by GitHub
parent c12b8f51c1
commit 473bd84c24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 218 additions and 86 deletions

View file

@ -8,7 +8,6 @@ import { useIdentity } from '@/mastodon/identity_context';
import {
fetchRelationships,
followAccount,
unblockAccount,
unmuteAccount,
} from 'mastodon/actions/accounts';
import { openModal } from 'mastodon/actions/modal';
@ -59,7 +58,8 @@ export const FollowButton: React.FC<{
accountId?: string;
compact?: boolean;
labelLength?: 'auto' | 'short' | 'long';
}> = ({ accountId, compact, labelLength = 'auto' }) => {
className?: string;
}> = ({ accountId, compact, labelLength = 'auto', className }) => {
const intl = useIntl();
const dispatch = useAppDispatch();
const { signedIn } = useIdentity();
@ -96,12 +96,24 @@ export const FollowButton: React.FC<{
return;
} else if (relationship.muting) {
dispatch(unmuteAccount(accountId));
} else if (account && (relationship.following || relationship.requested)) {
} else if (account && relationship.following) {
dispatch(
openModal({ modalType: 'CONFIRM_UNFOLLOW', modalProps: { account } }),
);
} else if (account && relationship.requested) {
dispatch(
openModal({
modalType: 'CONFIRM_WITHDRAW_REQUEST',
modalProps: { account },
}),
);
} else if (relationship.blocking) {
dispatch(unblockAccount(accountId));
dispatch(
openModal({
modalType: 'CONFIRM_UNBLOCK',
modalProps: { account },
}),
);
} else {
dispatch(followAccount(accountId));
}
@ -144,7 +156,7 @@ export const FollowButton: React.FC<{
href='/settings/profile'
target='_blank'
rel='noopener'
className={classNames('button button-secondary', {
className={classNames(className, 'button button-secondary', {
'button--compact': compact,
})}
>
@ -158,13 +170,12 @@ export const FollowButton: React.FC<{
onClick={handleClick}
disabled={
relationship?.blocked_by ||
relationship?.blocking ||
(!(relationship?.following || relationship?.requested) &&
(account?.suspended || !!account?.moved))
}
secondary={following}
compact={compact}
className={following ? 'button--destructive' : undefined}
className={classNames(className, { 'button--destructive': following })}
>
{label}
</Button>