fix the bugs Tulir found - THANKS

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2018-03-09 23:37:42 +00:00
parent 023632e7e4
commit 14f29e4740
No known key found for this signature in database
GPG key ID: 3F879DA5AD802A5E
2 changed files with 13 additions and 9 deletions

View file

@ -162,11 +162,12 @@ export default class ReplyThread extends React.Component {
} }
html = `<blockquote data-mx-reply><a href="${makeEventPermalink(ev.getRoomId(), ev.getId())}">In reply to</a> ` html = `<blockquote data-mx-reply><a href="${makeEventPermalink(ev.getRoomId(), ev.getId())}">In reply to</a> `
+ `<a href="${makeUserPermalink(ev.getSender())}">${ev.getSender()}</a> ${html || body}</blockquote>`; + `<a href="${makeUserPermalink(ev.getSender())}">${ev.getSender()}</a><br>${html || body}</blockquote>`;
// `&lt;${ev.getSender()}&gt; ${html || body}</blockquote>`; const lines = body.trim().split('\n');
const lines = body.split('\n'); if (lines.length > 0) {
const first = `> <${ev.getSender()}> ${lines.shift()}`; lines[0] = `<${ev.getSender()}> ${lines[0]}`;
body = first + lines.map((line) => `> ${line}`).join('\n') + '\n'; body = lines.map((line) => `> ${line}`).join('\n') + '\n\n';
}
return {body, html}; return {body, html};
} }

View file

@ -753,10 +753,15 @@ export default class MessageComposerInput extends React.Component {
return true; return true;
} }
const replyingToEv = RoomViewStore.getQuotingEvent();
const mustSendHTML = Boolean(replyingToEv);
if (this.state.isRichtextEnabled) { if (this.state.isRichtextEnabled) {
// We should only send HTML if any block is styled or contains inline style // We should only send HTML if any block is styled or contains inline style
let shouldSendHTML = false; let shouldSendHTML = false;
if (mustSendHTML) shouldSendHTML = true;
const blocks = contentState.getBlocksAsArray(); const blocks = contentState.getBlocksAsArray();
if (blocks.some((block) => block.getType() !== 'unstyled')) { if (blocks.some((block) => block.getType() !== 'unstyled')) {
shouldSendHTML = true; shouldSendHTML = true;
@ -815,7 +820,7 @@ export default class MessageComposerInput extends React.Component {
const md = new Markdown(pt); const md = new Markdown(pt);
// if contains no HTML and we're not quoting (needing HTML) // if contains no HTML and we're not quoting (needing HTML)
if (md.isPlainText()) { if (md.isPlainText() && !mustSendHTML) {
contentText = md.toPlaintext(); contentText = md.toPlaintext();
} else { } else {
contentHTML = md.toHTML(); contentHTML = md.toHTML();
@ -830,8 +835,6 @@ export default class MessageComposerInput extends React.Component {
this.state.isRichtextEnabled ? 'html' : 'markdown', this.state.isRichtextEnabled ? 'html' : 'markdown',
); );
const replyingToEv = RoomViewStore.getQuotingEvent();
if (contentText.startsWith('/me')) { if (contentText.startsWith('/me')) {
if (replyingToEv) { if (replyingToEv) {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); 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) { if (replyingToEv) {
const replyContent = ReplyThread.getReplyEvContent(replyingToEv); const replyContent = ReplyThread.getReplyEvContent(replyingToEv);