diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index ea150bf9bc..82c8190518 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)); } };