From 21ac2b8f3a78ac0af2046eeab3afc838a22a1151 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 2 Oct 2021 15:28:21 +0400 Subject: [PATCH] Don't use MTP* for reply markup data. --- Telegram/CMakeLists.txt | 2 + Telegram/SourceFiles/api/api_sending.cpp | 6 +- Telegram/SourceFiles/apiwrap.cpp | 4 +- .../boxes/background_preview_box.cpp | 2 +- .../SourceFiles/chat_helpers/bot_keyboard.cpp | 8 +- .../data/data_scheduled_messages.cpp | 6 +- Telegram/SourceFiles/data/data_session.cpp | 2 +- .../admin_log/history_admin_log_item.cpp | 2 +- Telegram/SourceFiles/history/history.cpp | 16 +- Telegram/SourceFiles/history/history.h | 9 +- Telegram/SourceFiles/history/history_item.cpp | 10 +- Telegram/SourceFiles/history/history_item.h | 15 +- .../history/history_item_components.cpp | 177 +--------------- .../history/history_item_components.h | 53 +---- .../history/history_item_reply_markup.cpp | 197 ++++++++++++++++++ .../history/history_item_reply_markup.h | 83 ++++++++ .../SourceFiles/history/history_message.cpp | 102 +++++---- .../SourceFiles/history/history_message.h | 19 +- .../inline_bots/inline_bot_result.cpp | 11 +- .../inline_bots/inline_bot_result.h | 3 +- .../inline_bots/inline_bot_send_data.cpp | 16 +- .../inline_bots/inline_bot_send_data.h | 12 +- .../support/support_autocomplete.cpp | 4 +- 23 files changed, 425 insertions(+), 334 deletions(-) create mode 100644 Telegram/SourceFiles/history/history_item_reply_markup.cpp create mode 100644 Telegram/SourceFiles/history/history_item_reply_markup.h diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index a3ca3af67..fbc893d8d 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -636,6 +636,8 @@ PRIVATE history/history_item.h history/history_item_components.cpp history/history_item_components.h + history/history_item_reply_markup.cpp + history/history_item_reply_markup.h history/history_item_text.cpp history/history_item_text.h history/history_inner_widget.cpp diff --git a/Telegram/SourceFiles/api/api_sending.cpp b/Telegram/SourceFiles/api/api_sending.cpp index 554c54734..ad8743b6a 100644 --- a/Telegram/SourceFiles/api/api_sending.cpp +++ b/Telegram/SourceFiles/api/api_sending.cpp @@ -128,7 +128,7 @@ void SendExistingMedia( messagePostAuthor, media, caption, - MTPReplyMarkup()); + HistoryMessageMarkupData()); auto performRequest = [=](const auto &repeatRequest) -> void { auto &histories = history->owner().histories(); @@ -288,7 +288,7 @@ bool SendDice(Api::MessageToSend &message) { messagePostAuthor, TextWithEntities(), MTP_messageMediaDice(MTP_int(0), MTP_string(emoji)), - MTPReplyMarkup()); + HistoryMessageMarkupData()); const auto requestType = Data::Histories::RequestType::Send; histories.sendRequest(history, requestType, [=](Fn finish) { @@ -471,7 +471,7 @@ void SendConfirmedFile( messagePostAuthor, caption, media, - MTPReplyMarkup(), + HistoryMessageMarkupData(), groupId); } diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 154eb436e..a53718bb4 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -3839,7 +3839,7 @@ void ApiWrap::sendSharedContact( MTP_string(lastName), MTP_string(), // vcard MTP_long(userId.bare)), - MTPReplyMarkup()); + HistoryMessageMarkupData()); const auto media = MTP_inputMediaContact( MTP_string(phone), @@ -4103,7 +4103,7 @@ void ApiWrap::sendMessage(MessageToSend &&message) { messagePostAuthor, sending, media, - MTPReplyMarkup()); + HistoryMessageMarkupData()); histories.sendRequest(history, requestType, [=](Fn finish) { history->sendRequestId = request(MTPmessages_SendMessage( MTP_flags(sendFlags), diff --git a/Telegram/SourceFiles/boxes/background_preview_box.cpp b/Telegram/SourceFiles/boxes/background_preview_box.cpp index 1285000b9..64e82a007 100644 --- a/Telegram/SourceFiles/boxes/background_preview_box.cpp +++ b/Telegram/SourceFiles/boxes/background_preview_box.cpp @@ -304,7 +304,7 @@ bool ServiceCheck::checkRippleStartPosition(QPoint position) const { QString(), TextWithEntities{ TextUtilities::Clean(text) }, MTP_messageMediaEmpty(), - MTPReplyMarkup(), + HistoryMessageMarkupData(), groupedId); return AdminLog::OwnedItem(delegate, item); } diff --git a/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp b/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp index 4fd649683..061ffec71 100644 --- a/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp +++ b/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp @@ -199,9 +199,9 @@ bool BotKeyboard::moderateKeyActivate(int key) { if (const auto markup = item->Get()) { if (key >= Qt::Key_1 && key <= Qt::Key_2) { const auto index = int(key - Qt::Key_1); - if (!markup->rows.empty() + if (!markup->data.rows.empty() && index >= 0 - && index < int(markup->rows.front().size())) { + && index < int(markup->data.rows.front().size())) { App::activateBotCommand(_controller, item, 0, index); return true; } @@ -257,14 +257,14 @@ bool BotKeyboard::updateMarkup(HistoryItem *to, bool force) { _singleUse = _forceReply || (markupFlags & ReplyMarkupFlag::SingleUse); if (const auto markup = to->Get()) { - _placeholder = markup->placeholder; + _placeholder = markup->data.placeholder; } else { _placeholder = QString(); } _impl = nullptr; if (auto markup = to->Get()) { - if (!markup->rows.empty()) { + if (!markup->data.rows.empty()) { _impl = std::make_unique( to, std::make_unique