mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-06 01:41:08 +00:00
Merge aa51b2ba37
into 9a2be25199
This commit is contained in:
commit
1188eecea0
|
@ -12,7 +12,7 @@ class FiltersController < ApplicationController
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@filter = current_account.custom_filters.build(action: :warn)
|
@filter = current_account.custom_filters.build(action: :warn)
|
||||||
@filter.keywords.build
|
@filter.keywords.build(resource_params.dig(:keywords_attributes, '0'))
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit; end
|
def edit; end
|
||||||
|
|
|
@ -41,12 +41,14 @@ const isHashtagLink = (
|
||||||
interface TargetParams {
|
interface TargetParams {
|
||||||
hashtag?: string;
|
hashtag?: string;
|
||||||
accountId?: string;
|
accountId?: string;
|
||||||
|
hashtagUrl?: URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const HashtagMenuController: React.FC = () => {
|
export const HashtagMenuController: React.FC = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [{ accountId, hashtag }, setTargetParams] = useState<TargetParams>({});
|
const [{ accountId, hashtag, hashtagUrl }, setTargetParams] =
|
||||||
|
useState<TargetParams>({});
|
||||||
const targetRef = useRef<HTMLAnchorElement | null>(null);
|
const targetRef = useRef<HTMLAnchorElement | null>(null);
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const account = useAppSelector((state) =>
|
const account = useAppSelector((state) =>
|
||||||
|
@ -77,11 +79,21 @@ export const HashtagMenuController: React.FC = () => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hashtagUrl: URL = new URL('/filters', document.location.href);
|
||||||
|
hashtagUrl.searchParams.set(
|
||||||
|
'custom_filter[keywords_attributes][0][keyword]',
|
||||||
|
target.text,
|
||||||
|
);
|
||||||
|
hashtagUrl.searchParams.set(
|
||||||
|
'custom_filter[keywords_attributes][0][whole_word]',
|
||||||
|
'1',
|
||||||
|
);
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
targetRef.current = target;
|
targetRef.current = target;
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
setTargetParams({ hashtag, accountId });
|
setTargetParams({ hashtag, accountId, hashtagUrl });
|
||||||
};
|
};
|
||||||
|
|
||||||
document.addEventListener('click', handleClick, { capture: true });
|
document.addEventListener('click', handleClick, { capture: true });
|
||||||
|
@ -116,11 +128,11 @@ export const HashtagMenuController: React.FC = () => {
|
||||||
text: intl.formatMessage(messages.muteHashtag, {
|
text: intl.formatMessage(messages.muteHashtag, {
|
||||||
hashtag,
|
hashtag,
|
||||||
}),
|
}),
|
||||||
href: '/filters',
|
href: hashtagUrl?.toString(),
|
||||||
dangerous: true,
|
dangerous: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[intl, hashtag, account],
|
[intl, hashtag, account, hashtagUrl],
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!open) {
|
if (!open) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user