fix: restore mx declarations removed by cleanup script
The automated unused-var cleanup incorrectly removed const mx = useMatrixClient() from MessageDeleteItem and ReportMessage components in Message.tsx. Both components use mx inside their useCallback closures (mx.redactEvent, mx.reportEvent). This caused a ReferenceError crash on the messages view in production. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -445,12 +445,13 @@ export const MessageDeleteItem = as<
|
||||
onClose?: () => void;
|
||||
}
|
||||
>(({ room, mEvent, onClose, ...props }, ref) => {
|
||||
const mx = useMatrixClient();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [deleteState, deleteMessage] = useAsyncCallback(
|
||||
useCallback(
|
||||
(eventId: string, reason?: string) =>
|
||||
mx.redactEvent(room.roomId, eventId, undefined, reason ? { reason } : undefined),
|
||||
[room],
|
||||
[mx, room],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -572,12 +573,13 @@ export const MessageReportItem = as<
|
||||
onClose?: () => void;
|
||||
}
|
||||
>(({ room, mEvent, onClose, ...props }, ref) => {
|
||||
const mx = useMatrixClient();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [reportState, reportMessage] = useAsyncCallback(
|
||||
useCallback(
|
||||
(eventId: string, score: number, reason: string) =>
|
||||
mx.reportEvent(room.roomId, eventId, score, reason),
|
||||
[room],
|
||||
[mx, room],
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user