mirror of
https://github.com/mastodon/mastodon.git
synced 2025-05-11 20:21:10 +00:00
Change unfollow button label from "Mutual" to "Unfollow" in web UI (#34392)
This commit is contained in:
parent
6a39f00745
commit
0e5be63fb3
|
@ -16,8 +16,7 @@ const messages = defineMessages({
|
||||||
unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
|
unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
|
||||||
follow: { id: 'account.follow', defaultMessage: 'Follow' },
|
follow: { id: 'account.follow', defaultMessage: 'Follow' },
|
||||||
followBack: { id: 'account.follow_back', defaultMessage: 'Follow back' },
|
followBack: { id: 'account.follow_back', defaultMessage: 'Follow back' },
|
||||||
mutual: { id: 'account.mutual', defaultMessage: 'Mutual' },
|
editProfile: { id: 'account.edit_profile', defaultMessage: 'Edit profile' },
|
||||||
edit_profile: { id: 'account.edit_profile', defaultMessage: 'Edit profile' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const FollowButton: React.FC<{
|
export const FollowButton: React.FC<{
|
||||||
|
@ -73,11 +72,9 @@ export const FollowButton: React.FC<{
|
||||||
if (!signedIn) {
|
if (!signedIn) {
|
||||||
label = intl.formatMessage(messages.follow);
|
label = intl.formatMessage(messages.follow);
|
||||||
} else if (accountId === me) {
|
} else if (accountId === me) {
|
||||||
label = intl.formatMessage(messages.edit_profile);
|
label = intl.formatMessage(messages.editProfile);
|
||||||
} else if (!relationship) {
|
} else if (!relationship) {
|
||||||
label = <LoadingIndicator />;
|
label = <LoadingIndicator />;
|
||||||
} else if (relationship.following && relationship.followed_by) {
|
|
||||||
label = intl.formatMessage(messages.mutual);
|
|
||||||
} else if (relationship.following || relationship.requested) {
|
} else if (relationship.following || relationship.requested) {
|
||||||
label = intl.formatMessage(messages.unfollow);
|
label = intl.formatMessage(messages.unfollow);
|
||||||
} else if (relationship.followed_by) {
|
} else if (relationship.followed_by) {
|
||||||
|
|
|
@ -37,10 +37,10 @@ import {
|
||||||
FollowingCounter,
|
FollowingCounter,
|
||||||
StatusesCounter,
|
StatusesCounter,
|
||||||
} from 'mastodon/components/counters';
|
} from 'mastodon/components/counters';
|
||||||
|
import { FollowButton } from 'mastodon/components/follow_button';
|
||||||
import { FormattedDateWrapper } from 'mastodon/components/formatted_date';
|
import { FormattedDateWrapper } from 'mastodon/components/formatted_date';
|
||||||
import { Icon } from 'mastodon/components/icon';
|
import { Icon } from 'mastodon/components/icon';
|
||||||
import { IconButton } from 'mastodon/components/icon_button';
|
import { IconButton } from 'mastodon/components/icon_button';
|
||||||
import { LoadingIndicator } from 'mastodon/components/loading_indicator';
|
|
||||||
import { ShortNumber } from 'mastodon/components/short_number';
|
import { ShortNumber } from 'mastodon/components/short_number';
|
||||||
import DropdownMenuContainer from 'mastodon/containers/dropdown_menu_container';
|
import DropdownMenuContainer from 'mastodon/containers/dropdown_menu_container';
|
||||||
import { DomainPill } from 'mastodon/features/account/components/domain_pill';
|
import { DomainPill } from 'mastodon/features/account/components/domain_pill';
|
||||||
|
@ -51,7 +51,6 @@ import { useIdentity } from 'mastodon/identity_context';
|
||||||
import { autoPlayGif, me, domain as localDomain } from 'mastodon/initial_state';
|
import { autoPlayGif, me, domain as localDomain } from 'mastodon/initial_state';
|
||||||
import type { Account } from 'mastodon/models/account';
|
import type { Account } from 'mastodon/models/account';
|
||||||
import type { DropdownMenu } from 'mastodon/models/dropdown_menu';
|
import type { DropdownMenu } from 'mastodon/models/dropdown_menu';
|
||||||
import type { Relationship } from 'mastodon/models/relationship';
|
|
||||||
import {
|
import {
|
||||||
PERMISSION_MANAGE_USERS,
|
PERMISSION_MANAGE_USERS,
|
||||||
PERMISSION_MANAGE_FEDERATION,
|
PERMISSION_MANAGE_FEDERATION,
|
||||||
|
@ -179,20 +178,6 @@ const titleFromAccount = (account: Account) => {
|
||||||
return `${prefix} (@${acct})`;
|
return `${prefix} (@${acct})`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const messageForFollowButton = (relationship?: Relationship) => {
|
|
||||||
if (!relationship) return messages.follow;
|
|
||||||
|
|
||||||
if (relationship.get('following') && relationship.get('followed_by')) {
|
|
||||||
return messages.mutual;
|
|
||||||
} else if (relationship.get('following') || relationship.get('requested')) {
|
|
||||||
return messages.unfollow;
|
|
||||||
} else if (relationship.get('followed_by')) {
|
|
||||||
return messages.followBack;
|
|
||||||
} else {
|
|
||||||
return messages.follow;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const dateFormatOptions: Intl.DateTimeFormatOptions = {
|
const dateFormatOptions: Intl.DateTimeFormatOptions = {
|
||||||
month: 'short',
|
month: 'short',
|
||||||
day: 'numeric',
|
day: 'numeric',
|
||||||
|
@ -215,20 +200,6 @@ export const AccountHeader: React.FC<{
|
||||||
const hidden = useAppSelector((state) => getAccountHidden(state, accountId));
|
const hidden = useAppSelector((state) => getAccountHidden(state, accountId));
|
||||||
const handleLinkClick = useLinks();
|
const handleLinkClick = useLinks();
|
||||||
|
|
||||||
const handleFollow = useCallback(() => {
|
|
||||||
if (!account) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (relationship?.following || relationship?.requested) {
|
|
||||||
dispatch(
|
|
||||||
openModal({ modalType: 'CONFIRM_UNFOLLOW', modalProps: { account } }),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
dispatch(followAccount(account.id));
|
|
||||||
}
|
|
||||||
}, [dispatch, account, relationship]);
|
|
||||||
|
|
||||||
const handleBlock = useCallback(() => {
|
const handleBlock = useCallback(() => {
|
||||||
if (!account) {
|
if (!account) {
|
||||||
return;
|
return;
|
||||||
|
@ -365,23 +336,6 @@ export const AccountHeader: React.FC<{
|
||||||
);
|
);
|
||||||
}, [dispatch, account]);
|
}, [dispatch, account]);
|
||||||
|
|
||||||
const handleInteractionModal = useCallback(() => {
|
|
||||||
if (!account) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatch(
|
|
||||||
openModal({
|
|
||||||
modalType: 'INTERACTION',
|
|
||||||
modalProps: {
|
|
||||||
type: 'follow',
|
|
||||||
accountId: account.id,
|
|
||||||
url: account.uri,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}, [dispatch, account]);
|
|
||||||
|
|
||||||
const handleOpenAvatar = useCallback(
|
const handleOpenAvatar = useCallback(
|
||||||
(e: React.MouseEvent) => {
|
(e: React.MouseEvent) => {
|
||||||
if (e.button !== 0 || e.ctrlKey || e.metaKey) {
|
if (e.button !== 0 || e.ctrlKey || e.metaKey) {
|
||||||
|
@ -417,10 +371,6 @@ export const AccountHeader: React.FC<{
|
||||||
});
|
});
|
||||||
}, [account]);
|
}, [account]);
|
||||||
|
|
||||||
const handleEditProfile = useCallback(() => {
|
|
||||||
window.open('/settings/profile', '_blank');
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleMouseEnter = useCallback(
|
const handleMouseEnter = useCallback(
|
||||||
({ currentTarget }: React.MouseEvent) => {
|
({ currentTarget }: React.MouseEvent) => {
|
||||||
if (autoPlayGif) {
|
if (autoPlayGif) {
|
||||||
|
@ -680,9 +630,12 @@ export const AccountHeader: React.FC<{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let actionBtn, bellBtn, lockedIcon, shareBtn;
|
let actionBtn: React.ReactNode,
|
||||||
|
bellBtn: React.ReactNode,
|
||||||
|
lockedIcon: React.ReactNode,
|
||||||
|
shareBtn: React.ReactNode;
|
||||||
|
|
||||||
const info = [];
|
const info: React.ReactNode[] = [];
|
||||||
|
|
||||||
if (me !== account.id && relationship?.blocking) {
|
if (me !== account.id && relationship?.blocking) {
|
||||||
info.push(
|
info.push(
|
||||||
|
@ -750,43 +703,17 @@ export const AccountHeader: React.FC<{
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (me !== account.id) {
|
if (relationship?.blocking) {
|
||||||
if (signedIn && !relationship) {
|
|
||||||
// Wait until the relationship is loaded
|
|
||||||
actionBtn = (
|
|
||||||
<Button disabled>
|
|
||||||
<LoadingIndicator />
|
|
||||||
</Button>
|
|
||||||
);
|
|
||||||
} else if (!relationship?.blocking) {
|
|
||||||
actionBtn = (
|
|
||||||
<Button
|
|
||||||
disabled={relationship?.blocked_by}
|
|
||||||
className={classNames({
|
|
||||||
'button--destructive':
|
|
||||||
relationship?.following || relationship?.requested,
|
|
||||||
})}
|
|
||||||
text={intl.formatMessage(messageForFollowButton(relationship))}
|
|
||||||
onClick={signedIn ? handleFollow : handleInteractionModal}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
actionBtn = (
|
|
||||||
<Button
|
|
||||||
text={intl.formatMessage(messages.unblock, {
|
|
||||||
name: account.username,
|
|
||||||
})}
|
|
||||||
onClick={handleBlock}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
actionBtn = (
|
actionBtn = (
|
||||||
<Button
|
<Button
|
||||||
text={intl.formatMessage(messages.edit_profile)}
|
text={intl.formatMessage(messages.unblock, {
|
||||||
onClick={handleEditProfile}
|
name: account.username,
|
||||||
|
})}
|
||||||
|
onClick={handleBlock}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
actionBtn = <FollowButton accountId={accountId} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (account.moved && !relationship?.following) {
|
if (account.moved && !relationship?.following) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user