mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-17 18:18:07 +00:00
[Glitch] Change unfollow button label from "Mutual" to "Unfollow" in web UI
Port 0e5be63fb3 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -36,10 +36,10 @@ import {
|
|||||||
} from 'flavours/glitch/components/badge';
|
} from 'flavours/glitch/components/badge';
|
||||||
import { Button } from 'flavours/glitch/components/button';
|
import { Button } from 'flavours/glitch/components/button';
|
||||||
import { CopyIconButton } from 'flavours/glitch/components/copy_icon_button';
|
import { CopyIconButton } from 'flavours/glitch/components/copy_icon_button';
|
||||||
|
import { FollowButton } from 'flavours/glitch/components/follow_button';
|
||||||
import { FormattedDateWrapper } from 'flavours/glitch/components/formatted_date';
|
import { FormattedDateWrapper } from 'flavours/glitch/components/formatted_date';
|
||||||
import { Icon } from 'flavours/glitch/components/icon';
|
import { Icon } from 'flavours/glitch/components/icon';
|
||||||
import { IconButton } from 'flavours/glitch/components/icon_button';
|
import { IconButton } from 'flavours/glitch/components/icon_button';
|
||||||
import { LoadingIndicator } from 'flavours/glitch/components/loading_indicator';
|
|
||||||
import DropdownMenuContainer from 'flavours/glitch/containers/dropdown_menu_container';
|
import DropdownMenuContainer from 'flavours/glitch/containers/dropdown_menu_container';
|
||||||
import { DomainPill } from 'flavours/glitch/features/account/components/domain_pill';
|
import { DomainPill } from 'flavours/glitch/features/account/components/domain_pill';
|
||||||
import AccountNoteContainer from 'flavours/glitch/features/account/containers/account_note_container';
|
import AccountNoteContainer from 'flavours/glitch/features/account/containers/account_note_container';
|
||||||
@@ -53,7 +53,6 @@ import {
|
|||||||
} from 'flavours/glitch/initial_state';
|
} from 'flavours/glitch/initial_state';
|
||||||
import type { Account } from 'flavours/glitch/models/account';
|
import type { Account } from 'flavours/glitch/models/account';
|
||||||
import type { DropdownMenu } from 'flavours/glitch/models/dropdown_menu';
|
import type { DropdownMenu } from 'flavours/glitch/models/dropdown_menu';
|
||||||
import type { Relationship } from 'flavours/glitch/models/relationship';
|
|
||||||
import {
|
import {
|
||||||
PERMISSION_MANAGE_USERS,
|
PERMISSION_MANAGE_USERS,
|
||||||
PERMISSION_MANAGE_FEDERATION,
|
PERMISSION_MANAGE_FEDERATION,
|
||||||
@@ -183,20 +182,6 @@ const titleFromAccount = (account: Account) => {
|
|||||||
return `${prefix} (@${acct})`;
|
return `${prefix} (@${acct})`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const messageForFollowButton = (relationship?: Relationship) => {
|
|
||||||
if (!relationship) return messages.follow;
|
|
||||||
|
|
||||||
if (relationship.get('requested')) {
|
|
||||||
return messages.cancel_follow_request;
|
|
||||||
} else if (relationship.get('following')) {
|
|
||||||
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',
|
||||||
@@ -219,20 +204,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;
|
||||||
@@ -369,23 +340,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) {
|
||||||
@@ -421,10 +375,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) {
|
||||||
@@ -684,9 +634,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?.followed_by) {
|
if (me !== account.id && relationship?.followed_by) {
|
||||||
info.push(
|
info.push(
|
||||||
@@ -763,27 +716,7 @@ 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 = (
|
actionBtn = (
|
||||||
<Button
|
<Button
|
||||||
text={intl.formatMessage(messages.unblock, {
|
text={intl.formatMessage(messages.unblock, {
|
||||||
@@ -792,14 +725,8 @@ export const AccountHeader: React.FC<{
|
|||||||
onClick={handleBlock}
|
onClick={handleBlock}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
actionBtn = (
|
actionBtn = <FollowButton accountId={accountId} />;
|
||||||
<Button
|
|
||||||
text={intl.formatMessage(messages.edit_profile)}
|
|
||||||
onClick={handleEditProfile}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (account.moved && !relationship?.following) {
|
if (account.moved && !relationship?.following) {
|
||||||
|
|||||||
Reference in New Issue
Block a user