null-guards

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/21833/head
Michael Telatynski 2020-04-27 23:53:32 +01:00
parent a5830c229e
commit 3e35cffae7
1 changed files with 3 additions and 2 deletions

View File

@ -28,8 +28,9 @@ const RedactedBody = React.forwardRef<any, IProps>(({mxEvent}, ref) => {
const cli: MatrixClient = useContext(MatrixClientContext);
let text = _t("Message deleted");
const redactedBecauseUserId = mxEvent.getUnsigned().redacted_because.sender;
if (redactedBecauseUserId && redactedBecauseUserId !== cli.getUserId()) {
const unsigned = mxEvent.getUnsigned();
const redactedBecauseUserId = unsigned && unsigned.redacted_because && unsigned.redacted_because.sender;
if (redactedBecauseUserId && redactedBecauseUserId !== mxEvent.getSender()) {
const room = cli.getRoom(mxEvent.getRoomId());
const sender = room && room.getMember(redactedBecauseUserId);
text = _t("Message deleted by %(name)s", { name: sender ? sender.name : redactedBecauseUserId });