From 00708bb8f4de65c419c17930f18a8abc380fb45b Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Wed, 31 May 2023 12:06:31 +0100 Subject: [PATCH] feat: include message context (if any) when reporting user --- src/components/common/messaging/Message.tsx | 1 + src/controllers/modals/components/Report.tsx | 2 ++ src/controllers/modals/types.ts | 1 + src/lib/ContextMenus.tsx | 6 +++++- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/common/messaging/Message.tsx b/src/components/common/messaging/Message.tsx index 693feadb..e4fec697 100644 --- a/src/components/common/messaging/Message.tsx +++ b/src/components/common/messaging/Message.tsx @@ -63,6 +63,7 @@ const Message = observer( ? useTriggerEvents("Menu", { user: message.author_id, contextualChannel: message.channel_id, + contextualMessage: message._id, // eslint-disable-next-line }) : undefined; diff --git a/src/controllers/modals/components/Report.tsx b/src/controllers/modals/components/Report.tsx index f3441e74..2f967cb9 100644 --- a/src/controllers/modals/components/Report.tsx +++ b/src/controllers/modals/components/Report.tsx @@ -41,6 +41,7 @@ const MessageContainer = styled.div` */ export default function ReportContent({ target, + messageId, ...props }: ModalProps<"report">) { const client = useClient(); @@ -124,6 +125,7 @@ export default function ReportContent({ ? "User" : "Server", report_reason: reason as any, + message_id: messageId, }, additional_context, }); diff --git a/src/controllers/modals/types.ts b/src/controllers/modals/types.ts index 8cdfa375..ff9a1970 100644 --- a/src/controllers/modals/types.ts +++ b/src/controllers/modals/types.ts @@ -182,6 +182,7 @@ export type Modal = { | { type: "report"; target: Server | User | Message; + messageId?: string; } | { type: "report_success"; diff --git a/src/lib/ContextMenus.tsx b/src/lib/ContextMenus.tsx index ab7a674e..2a4ce73d 100644 --- a/src/lib/ContextMenus.tsx +++ b/src/lib/ContextMenus.tsx @@ -47,6 +47,7 @@ interface ContextMenuData { unread?: boolean; queued?: QueuedMessage; contextualChannel?: string; + contextualMessage?: string; } type Action = @@ -112,7 +113,7 @@ type Action = key: string; state?: NotificationState; } - | { action: "report"; target: User | Server | Message }; + | { action: "report"; target: User | Server | Message; messageId?: string }; // ! FIXME: I dare someone to re-write this // Tip: This should just be split into separate context menus per logical area. @@ -454,6 +455,7 @@ export default function ContextMenus() { modalController.push({ type: "report", target: data.target, + messageId: data.messageId, }); break; } @@ -478,6 +480,7 @@ export default function ContextMenus() { queued, unread, contextualChannel: cxid, + contextualMessage, }: ContextMenuData) => { const elements: Children[] = []; let lastDivider = false; @@ -682,6 +685,7 @@ export default function ContextMenus() { { action: "report", target: user, + messageId: contextualMessage, }, "report_user", undefined,