Fix “Open original page” and “Add or Remove from lists” being included in account dropdown even when irrelevant (#34767)
Signed-off-by: Nicole Mikołajczyk <git@mkljczk.pl>
This commit is contained in:
parent
5dda094daa
commit
6b066eac2c
1 changed files with 64 additions and 53 deletions
|
@ -27,6 +27,7 @@ import { RelativeTimestamp } from 'mastodon/components/relative_timestamp';
|
||||||
import { ShortNumber } from 'mastodon/components/short_number';
|
import { ShortNumber } from 'mastodon/components/short_number';
|
||||||
import { Skeleton } from 'mastodon/components/skeleton';
|
import { Skeleton } from 'mastodon/components/skeleton';
|
||||||
import { VerifiedBadge } from 'mastodon/components/verified_badge';
|
import { VerifiedBadge } from 'mastodon/components/verified_badge';
|
||||||
|
import { useIdentity } from 'mastodon/identity_context';
|
||||||
import { me } from 'mastodon/initial_state';
|
import { me } from 'mastodon/initial_state';
|
||||||
import type { MenuItem } from 'mastodon/models/dropdown_menu';
|
import type { MenuItem } from 'mastodon/models/dropdown_menu';
|
||||||
import { useAppSelector, useAppDispatch } from 'mastodon/store';
|
import { useAppSelector, useAppDispatch } from 'mastodon/store';
|
||||||
|
@ -70,10 +71,12 @@ export const Account: React.FC<{
|
||||||
withBio?: boolean;
|
withBio?: boolean;
|
||||||
}> = ({ id, size = 46, hidden, minimal, defaultAction, withBio }) => {
|
}> = ({ id, size = 46, hidden, minimal, defaultAction, withBio }) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
const { signedIn } = useIdentity();
|
||||||
const account = useAppSelector((state) => state.accounts.get(id));
|
const account = useAppSelector((state) => state.accounts.get(id));
|
||||||
const relationship = useAppSelector((state) => state.relationships.get(id));
|
const relationship = useAppSelector((state) => state.relationships.get(id));
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const accountUrl = account?.url;
|
const accountUrl = account?.url;
|
||||||
|
const isRemote = account?.acct !== account?.username;
|
||||||
|
|
||||||
const handleBlock = useCallback(() => {
|
const handleBlock = useCallback(() => {
|
||||||
if (relationship?.blocking) {
|
if (relationship?.blocking) {
|
||||||
|
@ -116,6 +119,16 @@ export const Account: React.FC<{
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
} else if (defaultAction !== 'block') {
|
} else if (defaultAction !== 'block') {
|
||||||
|
arr = [];
|
||||||
|
|
||||||
|
if (isRemote && accountUrl) {
|
||||||
|
arr.push({
|
||||||
|
text: intl.formatMessage(messages.openOriginalPage),
|
||||||
|
href: accountUrl,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (signedIn) {
|
||||||
const handleAddToLists = () => {
|
const handleAddToLists = () => {
|
||||||
const openAddToListModal = () => {
|
const openAddToListModal = () => {
|
||||||
dispatch(
|
dispatch(
|
||||||
|
@ -156,26 +169,24 @@ export const Account: React.FC<{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
arr = [
|
arr.push({
|
||||||
{
|
|
||||||
text: intl.formatMessage(messages.addToLists),
|
text: intl.formatMessage(messages.addToLists),
|
||||||
action: handleAddToLists,
|
action: handleAddToLists,
|
||||||
},
|
});
|
||||||
];
|
|
||||||
|
|
||||||
if (accountUrl) {
|
|
||||||
arr.unshift(
|
|
||||||
{
|
|
||||||
text: intl.formatMessage(messages.openOriginalPage),
|
|
||||||
href: accountUrl,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
}, [dispatch, intl, id, accountUrl, relationship, defaultAction]);
|
}, [
|
||||||
|
dispatch,
|
||||||
|
intl,
|
||||||
|
id,
|
||||||
|
accountUrl,
|
||||||
|
relationship,
|
||||||
|
defaultAction,
|
||||||
|
isRemote,
|
||||||
|
signedIn,
|
||||||
|
]);
|
||||||
|
|
||||||
if (hidden) {
|
if (hidden) {
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue