Don't refresh large emoji messages when sent.

This commit is contained in:
John Preston 2019-08-07 15:38:26 +01:00
parent bc83df9d7f
commit d7f7a03eb4
6 changed files with 19 additions and 11 deletions

View File

@ -1629,11 +1629,10 @@ bool Session::checkEntitiesAndViewsUpdate(const MTPDmessage &data) {
return result; return result;
}(); }();
if (const auto existing = message(peerToChannel(peer), data.vid().v)) { if (const auto existing = message(peerToChannel(peer), data.vid().v)) {
existing->setText({ existing->updateSentContent({
qs(data.vmessage()), qs(data.vmessage()),
TextUtilities::EntitiesFromMTP(data.ventities().value_or_empty()) TextUtilities::EntitiesFromMTP(data.ventities().value_or_empty())
}); }, data.vmedia());
existing->updateSentMedia(data.vmedia());
existing->updateReplyMarkup(data.vreply_markup()); existing->updateReplyMarkup(data.vreply_markup());
existing->updateForwardedInfo(data.vfwd_from()); existing->updateForwardedInfo(data.vfwd_from());
existing->setViewsCount(data.vviews().value_or(-1)); existing->setViewsCount(data.vviews().value_or(-1));

View File

@ -594,7 +594,9 @@ HistoryItem *History::createItem(
result->removeMainView(); result->removeMainView();
} }
if (message.type() == mtpc_message) { if (message.type() == mtpc_message) {
result->updateSentMedia(message.c_message().vmedia()); result->updateSentContent(
result->originalText(),
message.c_message().vmedia());
} }
return result; return result;
} }

View File

@ -196,7 +196,9 @@ public:
virtual void applyEdition(const MTPDmessageService &message) { virtual void applyEdition(const MTPDmessageService &message) {
} }
void applyEditionToHistoryCleared(); void applyEditionToHistoryCleared();
virtual void updateSentMedia(const MTPMessageMedia *media) { virtual void updateSentContent(
const TextWithEntities &textWithEntities,
const MTPMessageMedia *media) {
} }
virtual void updateReplyMarkup(const MTPReplyMarkup *markup) { virtual void updateReplyMarkup(const MTPReplyMarkup *markup) {
} }

View File

@ -1014,13 +1014,17 @@ void HistoryMessage::applyEdition(const MTPDmessageService &message) {
} }
} }
void HistoryMessage::updateSentMedia(const MTPMessageMedia *media) { void HistoryMessage::updateSentContent(
const TextWithEntities &textWithEntities,
const MTPMessageMedia *media) {
const auto isolated = isolatedEmoji();
setText(textWithEntities);
if (_flags & MTPDmessage_ClientFlag::f_from_inline_bot) { if (_flags & MTPDmessage_ClientFlag::f_from_inline_bot) {
if (!media || !_media || !_media->updateInlineResultMedia(*media)) { if (!media || !_media || !_media->updateInlineResultMedia(*media)) {
refreshSentMedia(media); refreshSentMedia(media);
} }
_flags &= ~MTPDmessage_ClientFlag::f_from_inline_bot; _flags &= ~MTPDmessage_ClientFlag::f_from_inline_bot;
} else { } else if (media || _media || !isolated || isolated != isolatedEmoji()) {
if (!media || !_media || !_media->updateSentMedia(*media)) { if (!media || !_media || !_media->updateSentMedia(*media)) {
refreshSentMedia(media); refreshSentMedia(media);
} }

View File

@ -122,7 +122,9 @@ public:
void applyEdition(const MTPDmessage &message) override; void applyEdition(const MTPDmessage &message) override;
void applyEdition(const MTPDmessageService &message) override; void applyEdition(const MTPDmessageService &message) override;
void updateSentMedia(const MTPMessageMedia *media) override; void updateSentContent(
const TextWithEntities &textWithEntities,
const MTPMessageMedia *media) override;
void updateReplyMarkup(const MTPReplyMarkup *markup) override { void updateReplyMarkup(const MTPReplyMarkup *markup) override {
setReplyMarkup(markup); setReplyMarkup(markup);
} }

View File

@ -3817,11 +3817,10 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
item->id, item->id,
ApiWrap::RequestMessageDataCallback()); ApiWrap::RequestMessageDataCallback());
} }
item->setText({ item->updateSentContent({
sent.text, sent.text,
TextUtilities::EntitiesFromMTP(list.value_or_empty()) TextUtilities::EntitiesFromMTP(list.value_or_empty())
}); }, d.vmedia());
item->updateSentMedia(d.vmedia());
if (const auto channel = item->history()->peer->asChannel()) { if (const auto channel = item->history()->peer->asChannel()) {
channel->growSlowmodeLastMessage(d.vdate().v); channel->growSlowmodeLastMessage(d.vdate().v);
} }