fix(mod-tools): default-sanction sent the topic array index, not the topic id

sendDefaultSanction passed `selectedTopic` (the index into the topics array) as
the CFH topic id to DefaultSanctionMessageComposer, so the emulator applied the
default sanction against whatever topic happened to sit at that array position.
The sibling sendSanction (and the topic label) correctly use
`topics[selectedTopic].id`. Pass `category.id`, and move the `category` lookup
after the `selectedTopic === -1` guard (+ a `!category` guard).
This commit is contained in:
simoleo89
2026-06-13 16:42:24 +02:00
parent 93baedf206
commit 149b1db38c
@@ -75,14 +75,16 @@ export const ModToolsUserModActionView: FC<ModToolsUserModActionViewProps> = pro
{ {
if(isSendingRef.current) return; if(isSendingRef.current) return;
if(selectedTopic === -1) return sendAlert(LocalizeText('modtools.user.modaction.error.no.topic'));
const category = topics[selectedTopic]; const category = topics[selectedTopic];
if(selectedTopic === -1) return sendAlert(LocalizeText('modtools.user.modaction.error.no.topic')); if(!category) return sendAlert(LocalizeText('modtools.user.modaction.error.no.topic'));
const messageOrDefault = (message.trim().length === 0) ? LocalizeText(`help.cfh.topic.${ category.id }`) : message; const messageOrDefault = (message.trim().length === 0) ? LocalizeText(`help.cfh.topic.${ category.id }`) : message;
isSendingRef.current = true; isSendingRef.current = true;
SendMessageComposer(new DefaultSanctionMessageComposer(user.userId, selectedTopic, messageOrDefault)); SendMessageComposer(new DefaultSanctionMessageComposer(user.userId, category.id, messageOrDefault));
onCloseClick(); onCloseClick();
}; };