From d5b264b7a0df7748b045f5e13e985cdc83c6a5a9 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 8 Oct 2020 14:21:39 -0600 Subject: [PATCH] Fix parsing issue in event tile preview for appearance tab Fixes https://github.com/vector-im/element-web/issues/15419 --- .../views/elements/EventTilePreview.tsx | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/components/views/elements/EventTilePreview.tsx b/src/components/views/elements/EventTilePreview.tsx index 35019a901e..49cc2b8039 100644 --- a/src/components/views/elements/EventTilePreview.tsx +++ b/src/components/views/elements/EventTilePreview.tsx @@ -80,27 +80,28 @@ export default class EventTilePreview extends React.Component { private fakeEvent({userId, displayname, avatar_url: avatarUrl}: IState) { // Fake it till we make it - const event = new MatrixEvent(JSON.parse(`{ - "type": "m.room.message", - "sender": "${userId}", - "content": { - "m.new_content": { - "msgtype": "m.text", - "body": "${this.props.message}", - "displayname": "${displayname}", - "avatar_url": "${avatarUrl}" - }, - "msgtype": "m.text", - "body": "${this.props.message}", - "displayname": "${displayname}", - "avatar_url": "${avatarUrl}" + const rawEvent = { + type: "m.room.message", + sender: userId, + content: { + "m.new_content": { + msgtype: "m.text", + body: this.props.message, + displayname: displayname, + avatar_url: avatarUrl, }, - "unsigned": { - "age": 97 - }, - "event_id": "$9999999999999999999999999999999999999999999", - "room_id": "!999999999999999999:matrix.org" - }`)); + msgtype: "m.text", + body: this.props.message, + displayname: displayname, + avatar_url: avatarUrl, + }, + unsigned: { + age: 97, + }, + event_id: "$9999999999999999999999999999999999999999999", + room_id: "!999999999999999999:example.org", + }; + const event = new MatrixEvent(rawEvent); // Fake it more event.sender = {