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;
|
onClose?: () => void;
|
||||||
}
|
}
|
||||||
>(({ room, mEvent, onClose, ...props }, ref) => {
|
>(({ room, mEvent, onClose, ...props }, ref) => {
|
||||||
|
const mx = useMatrixClient();
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [deleteState, deleteMessage] = useAsyncCallback(
|
const [deleteState, deleteMessage] = useAsyncCallback(
|
||||||
useCallback(
|
useCallback(
|
||||||
(eventId: string, reason?: string) =>
|
(eventId: string, reason?: string) =>
|
||||||
mx.redactEvent(room.roomId, eventId, undefined, reason ? { reason } : undefined),
|
mx.redactEvent(room.roomId, eventId, undefined, reason ? { reason } : undefined),
|
||||||
[room],
|
[mx, room],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -572,12 +573,13 @@ export const MessageReportItem = as<
|
|||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
}
|
}
|
||||||
>(({ room, mEvent, onClose, ...props }, ref) => {
|
>(({ room, mEvent, onClose, ...props }, ref) => {
|
||||||
|
const mx = useMatrixClient();
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [reportState, reportMessage] = useAsyncCallback(
|
const [reportState, reportMessage] = useAsyncCallback(
|
||||||
useCallback(
|
useCallback(
|
||||||
(eventId: string, score: number, reason: string) =>
|
(eventId: string, score: number, reason: string) =>
|
||||||
mx.reportEvent(room.roomId, eventId, score, reason),
|
mx.reportEvent(room.roomId, eventId, score, reason),
|
||||||
[room],
|
[mx, room],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user