From 661073493b01af56e541f768656f5a52376206f7 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 16 Mar 2018 18:31:17 +0100 Subject: [PATCH] implement desired m.room.message->m.text fallbacks Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/elements/ReplyThread.js | 56 +++++++++++++++++--- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/src/components/views/elements/ReplyThread.js b/src/components/views/elements/ReplyThread.js index 650a3845e3..de6ff46610 100644 --- a/src/components/views/elements/ReplyThread.js +++ b/src/components/views/elements/ReplyThread.js @@ -161,12 +161,56 @@ export default class ReplyThread extends React.Component { if (html) html = this.stripHTMLReply(html); } - html = `
In reply to ` - + `${ev.getSender()}
${html || body}
`; - const lines = body.trim().split('\n'); - if (lines.length > 0) { - lines[0] = `<${ev.getSender()}> ${lines[0]}`; - body = lines.map((line) => `> ${line}`).join('\n') + '\n\n'; + const evLink = makeEventPermalink(ev.getRoomId(), ev.getId()); + const userLink = makeUserPermalink(ev.getSender()); + const mxid = ev.getSender(); + + // This fallback contains text that is explicitly EN. + switch (ev.getContent().msgtype) { + case 'm.text': + case 'm.notice': { + html = `
In reply to ${mxid}` + + `
${html || body}
`; + const lines = body.trim().split('\n'); + if (lines.length > 0) { + lines[0] = `<${mxid}> ${lines[0]}`; + body = lines.map((line) => `> ${line}`).join('\n') + '\n\n'; + } + break; + } + + case 'm.image': + html = `
In reply to ${mxid}` + + `
sent an image.
`; + body = `> <${mxid}> sent an image.\n\n${body}`; + break; + case 'm.video': + html = `
In reply to ${mxid}` + + `
sent a video.
`; + body = `> <${mxid}> sent a video.\n\n${body}`; + break; + case 'm.audio': + html = `
In reply to ${mxid}` + + `
sent an audio file.
`; + body = `> <${mxid}> sent an audio file.\n\n${body}`; + break; + case 'm.file': + html = `
In reply to ${mxid}` + + `
sent a file.
`; + body = `> <${mxid}> sent a file.\n\n${body}`; + break; + case 'm.emote': { + html = `
In reply to * ` + + `${mxid}
${html || body}
`; + const lines = body.trim().split('\n'); + if (lines.length > 0) { + lines[0] = `* <${mxid}> ${lines[0]}`; + body = lines.map((line) => `> ${line}`).join('\n') + '\n\n'; + } + break; + } + default: + return null; } return {body, html};