Compare commits

...

20 Commits

Author SHA1 Message Date
Sebastian Hädrich
07a801a2e0
Merge aa51b2ba37 into e9170e2de1 2025-07-10 01:01:53 +08:00
Sebastian Hädrich
aa51b2ba37
Pass hashtagUrl variable to useMemo() as dependency
Redo 59abde1
2025-06-26 03:54:59 +02:00
Sebastian Hädrich
418e5617cc
'hashtagUrl' is possibly 'undefined' 2025-06-26 03:53:49 +02:00
Sebastian Hädrich
f9f7018639
Linter 2025-06-26 03:51:02 +02:00
Sebastian Hädrich
1e672ae66e
fix: 🐛 Add hashtagUrl to target params
so that the variable is avialable outside of useEffect()
2025-06-26 03:49:41 +02:00
Sebastian Hädrich
fc18ec8bc1
Fix variable types 2025-06-26 03:49:06 +02:00
Sebastian Hädrich
cce87b7f35
Merge branch 'main' into mute-prefill 2025-06-25 23:01:35 +02:00
Sebastian Hädrich
35662387d2 Revert "Pass hashtagUrl variable to useMemo() as dependency"
This reverts commit 59abde12ee.
2025-06-25 23:00:20 +02:00
Sebastian Hädrich
ff7e62f3c7
Merge branch 'main' into mute-prefill 2025-06-25 13:34:34 +02:00
Sebastian Hädrich
59abde12ee
Pass hashtagUrl variable to useMemo() as dependency
See https://github.com/mastodon/mastodon/actions/runs/15860724453
2025-06-25 13:30:21 +02:00
Sebastian Hädrich
f70f096cae
Explicitly type variable
See https://github.com/mastodon/mastodon/actions/runs/15860724453
2025-06-25 13:25:55 +02:00
Sebastian Hädrich
70e595cb79
fix const assignment 2025-06-24 22:24:07 +02:00
Sebastian Hädrich
1b0122631e
Merge branch 'main' into mute-prefill 2025-06-24 17:36:08 +02:00
Sebastian Hädrich
c6bef7522b
Use validated resource_params instead of plain params
… as well as properly fill :keywords_attributes as collection rather than single model

Co-authored-by: Claire <claire.github-309c@sitedethib.com>

See: https://github.com/mastodon/mastodon/pull/35133#discussion_r2163366096

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
2025-06-24 17:35:41 +02:00
Sebastian Hädrich
f69352fe56
Use native escaping for hashtag URL 2025-06-24 13:33:00 +02:00
Sebastian Hädrich
34739f2cce
Merge branch 'main' into mute-prefill 2025-06-24 13:23:25 +02:00
Sebastian Hädrich
3f8b83ee59
Fix URL query param access 2025-06-22 02:24:29 +02:00
Sebastian Hädrich
5b98c1ba42
Pass pre-filled URL query params to keywords association build
to be pre-filled into the creation form
2025-06-22 02:04:56 +02:00
Sebastian Hädrich
6af65171f8
Prefix hashtag text with URL-encoded hashtag character 2025-06-22 01:40:27 +02:00
Sebastian Hädrich
81512ab4ca
Add URL query params to "Mute hashtags" request to /filters 2025-06-22 00:29:06 +02:00
2 changed files with 17 additions and 5 deletions

View File

@ -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

View File

@ -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) {