Merge pull request #3194 from matrix-org/bwindels/fix-history-redactions

Don't try to call bodyToHtml with an empty content
This commit is contained in:
Bruno Windels 2019-07-09 15:05:03 +00:00 committed by GitHub
commit 31723e9e5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -119,12 +119,13 @@ export default class EditHistoryMessage extends React.PureComponent {
const {mxEvent} = this.props; const {mxEvent} = this.props;
const originalContent = mxEvent.getOriginalContent(); const originalContent = mxEvent.getOriginalContent();
const content = originalContent["m.new_content"] || originalContent; const content = originalContent["m.new_content"] || originalContent;
const contentElements = HtmlUtils.bodyToHtml(content, null, {stripReplyFallback: true});
let contentContainer; let contentContainer;
if (mxEvent.isRedacted()) { if (mxEvent.isRedacted()) {
const UnknownBody = sdk.getComponent('messages.UnknownBody'); const UnknownBody = sdk.getComponent('messages.UnknownBody');
contentContainer = <UnknownBody mxEvent={this.props.mxEvent} />; contentContainer = <UnknownBody mxEvent={this.props.mxEvent} />;
} else if (mxEvent.getContent().msgtype === "m.emote") { } else {
const contentElements = HtmlUtils.bodyToHtml(content, null, {stripReplyFallback: true});
if (mxEvent.getContent().msgtype === "m.emote") {
const name = mxEvent.sender ? mxEvent.sender.name : mxEvent.getSender(); const name = mxEvent.sender ? mxEvent.sender.name : mxEvent.getSender();
contentContainer = ( contentContainer = (
<div className="mx_EventTile_content" ref="content">*&nbsp; <div className="mx_EventTile_content" ref="content">*&nbsp;
@ -135,6 +136,8 @@ export default class EditHistoryMessage extends React.PureComponent {
} else { } else {
contentContainer = <div className="mx_EventTile_content" ref="content">{contentElements}</div>; contentContainer = <div className="mx_EventTile_content" ref="content">{contentElements}</div>;
} }
}
const timestamp = formatTime(new Date(mxEvent.getTs()), this.props.isTwelveHour); const timestamp = formatTime(new Date(mxEvent.getTs()), this.props.isTwelveHour);
const isSending = (['sending', 'queued', 'encrypting'].indexOf(this.state.sendStatus) !== -1); const isSending = (['sending', 'queued', 'encrypting'].indexOf(this.state.sendStatus) !== -1);
const classes = classNames({ const classes = classNames({