Merge pull request #1956 from matrix-org/t3chguy/show_redacted_sticker
show redacted stickers like other redacted messagespull/21833/head
commit
038b43aabd
|
@ -62,18 +62,25 @@ module.exports = React.createClass({
|
||||||
'm.audio': sdk.getComponent('messages.MAudioBody'),
|
'm.audio': sdk.getComponent('messages.MAudioBody'),
|
||||||
'm.video': sdk.getComponent('messages.MVideoBody'),
|
'm.video': sdk.getComponent('messages.MVideoBody'),
|
||||||
};
|
};
|
||||||
|
const evTypes = {
|
||||||
|
'm.sticker': sdk.getComponent('messages.MStickerBody'),
|
||||||
|
};
|
||||||
|
|
||||||
const content = this.props.mxEvent.getContent();
|
const content = this.props.mxEvent.getContent();
|
||||||
|
const type = this.props.mxEvent.getType();
|
||||||
const msgtype = content.msgtype;
|
const msgtype = content.msgtype;
|
||||||
let BodyType = UnknownBody;
|
let BodyType = UnknownBody;
|
||||||
|
if (!this.props.mxEvent.isRedacted()) {
|
||||||
|
// only resolve BodyType if event is not redacted
|
||||||
if (msgtype && bodyTypes[msgtype]) {
|
if (msgtype && bodyTypes[msgtype]) {
|
||||||
BodyType = bodyTypes[msgtype];
|
BodyType = bodyTypes[msgtype];
|
||||||
} else if (this.props.mxEvent.getType() === 'm.sticker') {
|
} else if (type && evTypes[type]) {
|
||||||
BodyType = sdk.getComponent('messages.MStickerBody');
|
BodyType = evTypes[type];
|
||||||
} else if (content.url) {
|
} else if (content.url) {
|
||||||
// Fallback to MFileBody if there's a content URL
|
// Fallback to MFileBody if there's a content URL
|
||||||
BodyType = bodyTypes['m.file'];
|
BodyType = bodyTypes['m.file'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return <BodyType
|
return <BodyType
|
||||||
ref="body" mxEvent={this.props.mxEvent}
|
ref="body" mxEvent={this.props.mxEvent}
|
||||||
|
|
|
@ -490,7 +490,7 @@ module.exports = withMatrixClient(React.createClass({
|
||||||
}
|
}
|
||||||
|
|
||||||
const isSending = (['sending', 'queued', 'encrypting'].indexOf(this.props.eventSendStatus) !== -1);
|
const isSending = (['sending', 'queued', 'encrypting'].indexOf(this.props.eventSendStatus) !== -1);
|
||||||
const isRedacted = (eventType === 'm.room.message') && this.props.isRedacted;
|
const isRedacted = isMessageEvent(this.props.mxEvent) && this.props.isRedacted;
|
||||||
const isEncryptionFailure = this.props.mxEvent.isDecryptionFailure();
|
const isEncryptionFailure = this.props.mxEvent.isDecryptionFailure();
|
||||||
|
|
||||||
const classes = classNames({
|
const classes = classNames({
|
||||||
|
@ -715,9 +715,15 @@ module.exports = withMatrixClient(React.createClass({
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// XXX this'll eventually be dynamic based on the fields once we have extensible event types
|
||||||
|
const messageTypes = ['m.room.message', 'm.sticker'];
|
||||||
|
function isMessageEvent(ev) {
|
||||||
|
return (messageTypes.includes(ev.getType()));
|
||||||
|
}
|
||||||
|
|
||||||
module.exports.haveTileForEvent = function(e) {
|
module.exports.haveTileForEvent = function(e) {
|
||||||
// Only messages have a tile (black-rectangle) if redacted
|
// Only messages have a tile (black-rectangle) if redacted
|
||||||
if (e.isRedacted() && e.getType() !== 'm.room.message') return false;
|
if (e.isRedacted() && !isMessageEvent(e)) return false;
|
||||||
|
|
||||||
const handler = getHandlerTile(e);
|
const handler = getHandlerTile(e);
|
||||||
if (handler === undefined) return false;
|
if (handler === undefined) return false;
|
||||||
|
|
Loading…
Reference in New Issue