From f68e4d9d59b51217af0f9a915f3359417687668d Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 14 Jul 2020 19:23:14 +0300 Subject: [PATCH] Fixed sending of PlayGame user action. --- Telegram/SourceFiles/api/api_bot.cpp | 10 ++---- .../SourceFiles/api/api_send_progress.cpp | 33 ++++++++++--------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/Telegram/SourceFiles/api/api_bot.cpp b/Telegram/SourceFiles/api/api_bot.cpp index 2b3b5eff6..543e779d3 100644 --- a/Telegram/SourceFiles/api/api_bot.cpp +++ b/Telegram/SourceFiles/api/api_bot.cpp @@ -48,7 +48,6 @@ void SendBotCallbackData( } using ButtonType = HistoryMessageMarkupButton::Type; - const auto gameProgressType = Api::SendProgressType::PlayGame; const auto isGame = (button->type == ButtonType::Game); auto flags = MTPmessages_GetBotCallbackAnswer::Flags(0); @@ -87,12 +86,9 @@ void SendBotCallbackData( link, item->fullId()); BotGameUrlClickHandler(bot, scoreLink).onClick({}); - - if (history->mySendActionUpdated(gameProgressType, true)) { - session->sendProgressManager().update( - history, - gameProgressType); - } + session->sendProgressManager().update( + history, + Api::SendProgressType::PlayGame); } }); }).fail([=](const RPCError &error, auto id) { diff --git a/Telegram/SourceFiles/api/api_send_progress.cpp b/Telegram/SourceFiles/api/api_send_progress.cpp index 6666bde2e..2ee9a5bd3 100644 --- a/Telegram/SourceFiles/api/api_send_progress.cpp +++ b/Telegram/SourceFiles/api/api_send_progress.cpp @@ -62,21 +62,24 @@ void SendProgressManager::send( SendProgressType type, int32 progress) { using Type = SendProgressType; - MTPsendMessageAction action; - switch (type) { - case Type::Typing: action = MTP_sendMessageTypingAction(); break; - case Type::RecordVideo: action = MTP_sendMessageRecordVideoAction(); break; - case Type::UploadVideo: action = MTP_sendMessageUploadVideoAction(MTP_int(progress)); break; - case Type::RecordVoice: action = MTP_sendMessageRecordAudioAction(); break; - case Type::UploadVoice: action = MTP_sendMessageUploadAudioAction(MTP_int(progress)); break; - case Type::RecordRound: action = MTP_sendMessageRecordRoundAction(); break; - case Type::UploadRound: action = MTP_sendMessageUploadRoundAction(MTP_int(progress)); break; - case Type::UploadPhoto: action = MTP_sendMessageUploadPhotoAction(MTP_int(progress)); break; - case Type::UploadFile: action = MTP_sendMessageUploadDocumentAction(MTP_int(progress)); break; - case Type::ChooseLocation: action = MTP_sendMessageGeoLocationAction(); break; - case Type::ChooseContact: action = MTP_sendMessageChooseContactAction(); break; - case Type::PlayGame: action = MTP_sendMessageGamePlayAction(); break; - } + const auto action = [&]() -> MTPsendMessageAction { + const auto p = MTP_int(progress); + switch (type) { + case Type::Typing: return MTP_sendMessageTypingAction(); + case Type::RecordVideo: return MTP_sendMessageRecordVideoAction(); + case Type::UploadVideo: return MTP_sendMessageUploadVideoAction(p); + case Type::RecordVoice: return MTP_sendMessageRecordAudioAction(); + case Type::UploadVoice: return MTP_sendMessageUploadAudioAction(p); + case Type::RecordRound: return MTP_sendMessageRecordRoundAction(); + case Type::UploadRound: return MTP_sendMessageUploadRoundAction(p); + case Type::UploadPhoto: return MTP_sendMessageUploadPhotoAction(p); + case Type::UploadFile: return MTP_sendMessageUploadDocumentAction(p); + case Type::ChooseLocation: return MTP_sendMessageGeoLocationAction(); + case Type::ChooseContact: return MTP_sendMessageChooseContactAction(); + case Type::PlayGame: return MTP_sendMessageGamePlayAction(); + default: return MTP_sendMessageTypingAction(); + } + }(); const auto requestId = _session->api().request(MTPmessages_SetTyping( history->peer->input, action