Fix sending messages with links.

This commit is contained in:
John Preston 2019-05-28 14:33:35 +02:00
parent 39a80e9de7
commit f0ed5640db
1 changed files with 25 additions and 24 deletions

View File

@ -391,7 +391,7 @@ MainWidget::MainWidget(
) | rpl::start_with_next([=](const Media::Player::TrackState &state) { ) | rpl::start_with_next([=](const Media::Player::TrackState &state) {
handleAudioUpdate(state); handleAudioUpdate(state);
}, lifetime()); }, lifetime());
subscribe(session().calls().currentCallChanged(), [this](Calls::Call *call) { setCurrentCall(call); }); subscribe(session().calls().currentCallChanged(), [this](Calls::Call *call) { setCurrentCall(call); });
session().data().currentExportView( session().data().currentExportView(
@ -3784,30 +3784,31 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
if (!IsServerMsgId(d.vid.v)) { if (!IsServerMsgId(d.vid.v)) {
LOG(("API Error: Bad msgId got from server: %1").arg(d.vid.v)); LOG(("API Error: Bad msgId got from server: %1").arg(d.vid.v));
} else if (randomId) { } else if (randomId) {
PeerId peerId = 0; const auto sent = session().data().messageSentData(randomId);
QString text; const auto lookupMessage = [&] {
session().data().registerMessageSentData(randomId, peerId, text); return sent.peerId
? session().data().message(
const auto wasAlready = (peerId != 0) peerToChannel(sent.peerId),
&& (session().data().message(peerToChannel(peerId), d.vid.v) != nullptr); d.vid.v)
: nullptr;
};
const auto wasAlready = (lookupMessage() != nullptr);
feedUpdate(MTP_updateMessageID(d.vid, MTP_long(randomId))); // ignore real date feedUpdate(MTP_updateMessageID(d.vid, MTP_long(randomId))); // ignore real date
if (peerId) { if (const auto item = lookupMessage()) {
if (auto item = session().data().message(peerToChannel(peerId), d.vid.v)) { if (d.has_entities() && !MentionUsersLoaded(&session(), d.ventities)) {
if (d.has_entities() && !MentionUsersLoaded(&session(), d.ventities)) { session().api().requestMessageData(
session().api().requestMessageData( item->history()->peer->asChannel(),
item->history()->peer->asChannel(), item->id,
item->id, ApiWrap::RequestMessageDataCallback());
ApiWrap::RequestMessageDataCallback()); }
} const auto entities = d.has_entities()
const auto entities = d.has_entities() ? TextUtilities::EntitiesFromMTP(d.ventities.v)
? TextUtilities::EntitiesFromMTP(d.ventities.v) : EntitiesInText();
: EntitiesInText(); const auto media = d.has_media() ? &d.vmedia : nullptr;
const auto media = d.has_media() ? &d.vmedia : nullptr; item->setText({ sent.text, entities });
item->setText({ text, entities }); item->updateSentMedia(media);
item->updateSentMedia(media); if (!wasAlready) {
if (!wasAlready) { item->indexAsNewItem();
item->indexAsNewItem();
}
} }
} }
} }