Fix rich text entities in log entry original.

This commit is contained in:
John Preston 2017-06-24 20:21:01 +03:00
parent 0a9db8533b
commit ae56c5266f
2 changed files with 16 additions and 6 deletions

View File

@ -349,9 +349,10 @@ void GenerateItems(gsl::not_null<History*> history, LocalIdManager &idManager, c
auto applyServiceAction = false; auto applyServiceAction = false;
auto detachExistingItem = false; auto detachExistingItem = false;
auto body = history->createItem(PrepareLogMessage(action.vnew_message, idManager.next(), date.v), applyServiceAction, detachExistingItem); auto body = history->createItem(PrepareLogMessage(action.vnew_message, idManager.next(), date.v), applyServiceAction, detachExistingItem);
if (!oldValue.text.isEmpty()) { if (oldValue.text.isEmpty()) {
body->addLogEntryOriginal(id, lang(canHaveCaption ? lng_admin_log_previous_caption : lng_admin_log_previous_message), oldValue); oldValue = PrepareText(QString(), lang(lng_admin_log_empty_text));
} }
body->addLogEntryOriginal(id, lang(canHaveCaption ? lng_admin_log_previous_caption : lng_admin_log_previous_message), oldValue);
addPart(body); addPart(body);
}; };

View File

@ -49,7 +49,7 @@ TextParseOptions _webpageTitleOptions = {
Qt::LayoutDirectionAuto, // dir Qt::LayoutDirectionAuto, // dir
}; };
TextParseOptions _webpageDescriptionOptions = { TextParseOptions _webpageDescriptionOptions = {
TextParseLinks | TextParseMentions | TextParseHashtags | TextParseMultiline | TextParseRichText, // flags TextParseLinks | TextParseMentions | TextParseHashtags | TextParseMultiline | TextParseRichText | TextParseMono, // flags
0, // maxw 0, // maxw
0, // maxh 0, // maxh
Qt::LayoutDirectionAuto, // dir Qt::LayoutDirectionAuto, // dir
@ -3726,7 +3726,10 @@ void HistoryGame::initDimensions() {
if (!_attach) { if (!_attach) {
text += _parent->skipBlock(); text += _parent->skipBlock();
} }
_description.setText(st::webPageDescriptionStyle, text, _webpageDescriptionOptions); auto marked = TextWithEntities { text };
auto parseFlags = TextParseLinks | TextParseMultiline | TextParseRichText;
textParseEntities(marked.text, parseFlags, &marked.entities);
_description.setMarkedText(st::webPageDescriptionStyle, marked, _webpageDescriptionOptions);
} }
} }
if (_title.isEmpty() && !title.isEmpty()) { if (_title.isEmpty() && !title.isEmpty()) {
@ -4151,7 +4154,10 @@ void HistoryInvoice::fillFromData(const MTPDmessageMediaInvoice &data) {
// init strings // init strings
auto description = qs(data.vdescription); auto description = qs(data.vdescription);
if (!description.isEmpty()) { if (!description.isEmpty()) {
_description.setText(st::webPageDescriptionStyle, description, _webpageDescriptionOptions); auto marked = TextWithEntities { description };
auto parseFlags = TextParseLinks | TextParseMultiline | TextParseRichText;
textParseEntities(marked.text, parseFlags, &marked.entities);
_description.setMarkedText(st::webPageDescriptionStyle, marked, _webpageDescriptionOptions);
} }
auto title = textOneLine(qs(data.vtitle)); auto title = textOneLine(qs(data.vtitle));
if (!title.isEmpty()) { if (!title.isEmpty()) {
@ -4457,7 +4463,10 @@ HistoryLocation::HistoryLocation(gsl::not_null<HistoryItem*> parent, const Locat
_title.setText(st::webPageTitleStyle, textClean(title), _webpageTitleOptions); _title.setText(st::webPageTitleStyle, textClean(title), _webpageTitleOptions);
} }
if (!description.isEmpty()) { if (!description.isEmpty()) {
_description.setText(st::webPageDescriptionStyle, textClean(description), _webpageDescriptionOptions); auto marked = TextWithEntities { textClean(description) };
auto parseFlags = TextParseLinks | TextParseMultiline | TextParseRichText;
textParseEntities(marked.text, parseFlags, &marked.entities);
_description.setMarkedText(st::webPageDescriptionStyle, marked, _webpageDescriptionOptions);
} }
} }