From d4d2eef2915315e04a2ba63a7aff3b081cb67f6a Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 13 Nov 2023 10:40:44 +0400 Subject: [PATCH] Fix clearing cloud draft on message send. Regression was introduced in 20ba417ddd. --- Telegram/SourceFiles/apiwrap.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index ea150bf9b..82c819051 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -3582,11 +3582,12 @@ void ApiWrap::sendMessage(MessageToSend &&message) { sendAction(action); const auto clearCloudDraft = action.clearDraft; + const auto draftTopicRootId = action.replyTo.topicRootId; const auto replyTo = action.replyTo.messageId ? peer->owner().message(action.replyTo.messageId) : nullptr; - const auto topicRootId = action.replyTo.topicRootId - ? action.replyTo.topicRootId + const auto topicRootId = draftTopicRootId + ? draftTopicRootId : replyTo ? replyTo->topicRootId() : Data::ForumTopic::kGeneralId; @@ -3626,7 +3627,10 @@ void ApiWrap::sendMessage(MessageToSend &&message) { TextUtilities::Trim(sending); _session->data().registerMessageRandomId(randomId, newId); - _session->data().registerMessageSentData(randomId, peer->id, sending.text); + _session->data().registerMessageSentData( + randomId, + peer->id, + sending.text); MTPstring msgText(MTP_string(sending.text)); auto flags = NewMessageFlags(peer); @@ -3688,8 +3692,8 @@ void ApiWrap::sendMessage(MessageToSend &&message) { if (clearCloudDraft) { sendFlags |= MTPmessages_SendMessage::Flag::f_clear_draft; mediaFlags |= MTPmessages_SendMedia::Flag::f_clear_draft; - history->clearCloudDraft(topicRootId); - history->startSavingCloudDraft(topicRootId); + history->clearCloudDraft(draftTopicRootId); + history->startSavingCloudDraft(draftTopicRootId); } const auto sendAs = action.options.sendAs; const auto messageFromId = sendAs @@ -3726,7 +3730,7 @@ void ApiWrap::sendMessage(MessageToSend &&message) { const MTP::Response &response) { if (clearCloudDraft) { history->finishSavingCloudDraft( - topicRootId, + draftTopicRootId, UnixtimeFromMsgId(response.outerMsgId)); } }; @@ -3740,7 +3744,7 @@ void ApiWrap::sendMessage(MessageToSend &&message) { } if (clearCloudDraft) { history->finishSavingCloudDraft( - topicRootId, + draftTopicRootId, UnixtimeFromMsgId(response.outerMsgId)); } };