From 14f29e47406e3103758ecc76266664689a7c11c1 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Fri, 9 Mar 2018 23:37:42 +0000
Subject: [PATCH] fix the bugs Tulir found - THANKS
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/components/views/elements/ReplyThread.js | 11 ++++++-----
src/components/views/rooms/MessageComposerInput.js | 11 +++++++----
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/components/views/elements/ReplyThread.js b/src/components/views/elements/ReplyThread.js
index 059df7a01c..650a3845e3 100644
--- a/src/components/views/elements/ReplyThread.js
+++ b/src/components/views/elements/ReplyThread.js
@@ -162,11 +162,12 @@ export default class ReplyThread extends React.Component {
}
html = `
In reply to `
- + `${ev.getSender()} ${html || body}
`;
- // `<${ev.getSender()}> ${html || body}`;
- const lines = body.split('\n');
- const first = `> <${ev.getSender()}> ${lines.shift()}`;
- body = first + lines.map((line) => `> ${line}`).join('\n') + '\n';
+ + `${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';
+ }
return {body, html};
}
diff --git a/src/components/views/rooms/MessageComposerInput.js b/src/components/views/rooms/MessageComposerInput.js
index 1b3299ab94..956091215f 100644
--- a/src/components/views/rooms/MessageComposerInput.js
+++ b/src/components/views/rooms/MessageComposerInput.js
@@ -753,10 +753,15 @@ export default class MessageComposerInput extends React.Component {
return true;
}
+ const replyingToEv = RoomViewStore.getQuotingEvent();
+ const mustSendHTML = Boolean(replyingToEv);
+
if (this.state.isRichtextEnabled) {
// We should only send HTML if any block is styled or contains inline style
let shouldSendHTML = false;
+ if (mustSendHTML) shouldSendHTML = true;
+
const blocks = contentState.getBlocksAsArray();
if (blocks.some((block) => block.getType() !== 'unstyled')) {
shouldSendHTML = true;
@@ -815,7 +820,7 @@ export default class MessageComposerInput extends React.Component {
const md = new Markdown(pt);
// if contains no HTML and we're not quoting (needing HTML)
- if (md.isPlainText()) {
+ if (md.isPlainText() && !mustSendHTML) {
contentText = md.toPlaintext();
} else {
contentHTML = md.toHTML();
@@ -830,8 +835,6 @@ export default class MessageComposerInput extends React.Component {
this.state.isRichtextEnabled ? 'html' : 'markdown',
);
- const replyingToEv = RoomViewStore.getQuotingEvent();
-
if (contentText.startsWith('/me')) {
if (replyingToEv) {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
@@ -850,7 +853,7 @@ export default class MessageComposerInput extends React.Component {
}
- let content = contentHTML || replyingToEv ? sendHtmlFn(contentText, contentHTML) : sendTextFn(contentText);
+ let content = contentHTML ? sendHtmlFn(contentText, contentHTML) : sendTextFn(contentText);
if (replyingToEv) {
const replyContent = ReplyThread.getReplyEvContent(replyingToEv);