This commit is contained in:
Sebastian Hädrich 2025-07-10 08:06:40 +00:00 committed by GitHub
commit f6b1a81592
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 5 deletions

View File

@ -12,7 +12,7 @@ class FiltersController < ApplicationController
def new
@filter = current_account.custom_filters.build(action: :warn)
@filter.keywords.build
@filter.keywords.build(resource_params.dig(:keywords_attributes, '0'))
end
def edit; end

View File

@ -41,12 +41,14 @@ const isHashtagLink = (
interface TargetParams {
hashtag?: string;
accountId?: string;
hashtagUrl?: URL;
}
export const HashtagMenuController: React.FC = () => {
const intl = useIntl();
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 location = useLocation();
const account = useAppSelector((state) =>
@ -77,11 +79,21 @@ export const HashtagMenuController: React.FC = () => {
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.stopPropagation();
targetRef.current = target;
setOpen(true);
setTargetParams({ hashtag, accountId });
setTargetParams({ hashtag, accountId, hashtagUrl });
};
document.addEventListener('click', handleClick, { capture: true });
@ -116,11 +128,11 @@ export const HashtagMenuController: React.FC = () => {
text: intl.formatMessage(messages.muteHashtag, {
hashtag,
}),
href: '/filters',
href: hashtagUrl?.toString(),
dangerous: true,
},
],
[intl, hashtag, account],
[intl, hashtag, account, hashtagUrl],
);
if (!open) {