Do not display mute button in hashtag dropdown when unauthenticated (#36353)
Some checks failed
Check i18n / check-i18n (push) Waiting to run
Chromatic / Run Chromatic (push) Waiting to run
Check formatting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Bundler Audit / security (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (ruby) (push) Has been cancelled

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk 2025-10-05 16:24:54 +02:00 committed by GitHub
parent 80c8a84740
commit 62f91eddf4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -11,6 +11,8 @@ import type {
} from 'react-overlays/esm/usePopper'; } from 'react-overlays/esm/usePopper';
import { DropdownMenu } from 'mastodon/components/dropdown_menu'; import { DropdownMenu } from 'mastodon/components/dropdown_menu';
import { useIdentity } from 'mastodon/identity_context';
import type { MenuItem } from 'mastodon/models/dropdown_menu';
import { useAppSelector } from 'mastodon/store'; import { useAppSelector } from 'mastodon/store';
const messages = defineMessages({ const messages = defineMessages({
@ -45,6 +47,7 @@ interface TargetParams {
export const HashtagMenuController: React.FC = () => { export const HashtagMenuController: React.FC = () => {
const intl = useIntl(); const intl = useIntl();
const { signedIn } = useIdentity();
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [{ accountId, hashtag }, setTargetParams] = useState<TargetParams>({}); const [{ accountId, hashtag }, setTargetParams] = useState<TargetParams>({});
const targetRef = useRef<HTMLAnchorElement | null>(null); const targetRef = useRef<HTMLAnchorElement | null>(null);
@ -96,8 +99,8 @@ export const HashtagMenuController: React.FC = () => {
targetRef.current = null; targetRef.current = null;
}, [setOpen]); }, [setOpen]);
const menu = useMemo( const menu = useMemo(() => {
() => [ const arr: MenuItem[] = [
{ {
text: intl.formatMessage(messages.browseHashtag, { text: intl.formatMessage(messages.browseHashtag, {
hashtag, hashtag,
@ -111,17 +114,20 @@ export const HashtagMenuController: React.FC = () => {
}), }),
to: `/@${account?.acct}/tagged/${hashtag}`, to: `/@${account?.acct}/tagged/${hashtag}`,
}, },
null, ];
{
if (signedIn) {
arr.push(null, {
text: intl.formatMessage(messages.muteHashtag, { text: intl.formatMessage(messages.muteHashtag, {
hashtag, hashtag,
}), }),
href: '/filters', href: '/filters',
dangerous: true, dangerous: true,
}, });
], }
[intl, hashtag, account],
); return arr;
}, [intl, hashtag, account, signedIn]);
if (!open) { if (!open) {
return null; return null;