diff --git a/Telegram/SourceFiles/api/api_bot.cpp b/Telegram/SourceFiles/api/api_bot.cpp index 236eafad9b..8506ceedc6 100644 --- a/Telegram/SourceFiles/api/api_bot.cpp +++ b/Telegram/SourceFiles/api/api_bot.cpp @@ -46,6 +46,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include +// AyuGram includes +#include "ayu/utils/telegram_helpers.h" + + namespace Api { namespace { @@ -424,6 +428,7 @@ void ActivateBotCommand(ClickHandlerContext context, int row, int column) { const auto id = int32(button->buttonId); const auto chosen = [=](std::vector> result) { using Flag = MTPmessages_SendBotRequestedPeer::Flag; + markReadAfterAction(item->history()); peer->session().api().request(MTPmessages_SendBotRequestedPeer( MTP_flags(Flag::f_msg_id), peer->input(), @@ -573,6 +578,7 @@ void ActivateBotCommand(ClickHandlerContext context, int row, int column) { .suggestedUsername = suggestedUsername, .done = [=](not_null createdBot) { using Flag = MTPmessages_SendBotRequestedPeer::Flag; + markReadAfterAction(item->history()); peer->session().api().request( MTPmessages_SendBotRequestedPeer( MTP_flags(Flag::f_msg_id), diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 855cacec6d..8893dce20f 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -3664,12 +3664,6 @@ void ApiWrap::forwardMessages( shared->callback(); } - const auto &ghost = AyuSettings::ghost(_session); - if (!ghost.sendReadMessages() && ghost.markReadAfterAction() && history->lastMessage()) - { - readHistory(history->lastMessage()); - } - if (peer->isSelf() && _session->premium()) { ProcessRecentSelfForwards( _session, @@ -4046,6 +4040,7 @@ void ApiWrap::cancelLocalItem(not_null item) { void ApiWrap::sendShortcutMessages( not_null peer, BusinessShortcutId id) { + markReadAfterAction(peer->owner().history(peer)); auto ids = QVector(); auto randomIds = QVector(); request(MTPmessages_SendQuickReplyMessages( diff --git a/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp b/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp index 718c34a9b6..1b2e11a5e0 100644 --- a/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp +++ b/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp @@ -421,6 +421,16 @@ void readHistory(not_null message) { } } +void markReadAfterAction(not_null history) { + const auto &ghost = AyuSettings::ghost(&history->session()); + if (ghost.sendReadMessages() || !ghost.markReadAfterAction()) { + return; + } + if (const auto last = history->lastServerMessage()) { + readHistory(last); + } +} + QString formatTTL(int time, bool isDoc) { if (time == 0x7FFFFFFF) { return isDoc ? tr::ayu_OnePlayTTL(tr::now) : tr::ayu_OneViewTTL(tr::now); diff --git a/Telegram/SourceFiles/ayu/utils/telegram_helpers.h b/Telegram/SourceFiles/ayu/utils/telegram_helpers.h index 7251a756d1..7fbfee443a 100644 --- a/Telegram/SourceFiles/ayu/utils/telegram_helpers.h +++ b/Telegram/SourceFiles/ayu/utils/telegram_helpers.h @@ -73,6 +73,7 @@ bool isMessageHidden(not_null item); void MarkAsReadChatList(not_null list); void MarkAsReadThread(not_null thread); +void markReadAfterAction(not_null history); void readHistory(not_null message); QString formatTTL(int time, bool isDoc); diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index a77bbe09f1..705de7dbd2 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -64,8 +64,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include // AyuGram includes -#include "ayu/ayu_settings.h" -#include "ayu/utils/telegram_helpers.h" #include "ayu/features/forward/ayu_forward.h" @@ -1878,12 +1876,6 @@ ShareBox::SubmitCallback ShareBox::DefaultForwardCallback( const auto requestDone = [=]( const MTPUpdates &updates, mtpRequestId requestKey) { - const auto &ghost = AyuSettings::ghost(&history->owner().session()); - if (!ghost.sendReadMessages() && ghost.markReadAfterAction() && history->lastMessage()) - { - readHistory(history->lastMessage()); - } - if (showRecentForwardsToSelf) { ApiWrap::ProcessRecentSelfForwards( &threadHistory->session(), diff --git a/Telegram/SourceFiles/data/data_histories.cpp b/Telegram/SourceFiles/data/data_histories.cpp index 5b35b0d489..2f9fbea3ee 100644 --- a/Telegram/SourceFiles/data/data_histories.cpp +++ b/Telegram/SourceFiles/data/data_histories.cpp @@ -1109,6 +1109,7 @@ int Histories::sendPreparedMessage( Fn, FullReplyTo)> message, Fn done, Fn fail) { + markReadAfterAction(history); if (isCreatingTopic(history, replyTo.topicRootId)) { const auto id = ++_requestAutoincrement; const auto creatingId = FullMsgId( diff --git a/Telegram/SourceFiles/data/data_message_reactions.cpp b/Telegram/SourceFiles/data/data_message_reactions.cpp index ad5f6b0984..5caa80abc1 100644 --- a/Telegram/SourceFiles/data/data_message_reactions.cpp +++ b/Telegram/SourceFiles/data/data_message_reactions.cpp @@ -1873,6 +1873,7 @@ void Reactions::sendPaidRequest( return; } + markReadAfterAction(item->history()); const auto id = item->fullId(); const auto randomId = base::unixtime::mtproto_msg_id(); auto &api = _owner->session().api(); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 798a02db17..32b5efbd3e 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -2164,12 +2164,6 @@ void HistoryWidget::fileChosen(ChatHelpers::FileChosen &&data) { Data::InsertCustomEmoji(_field.data(), data.document); } } else if (_history) { - const auto &ghost = AyuSettings::ghost(&controller()->session()); - if (!ghost.sendReadMessages() && ghost.markReadAfterAction()) { - if (const auto lastMessage = history()->lastMessage()) { - readHistory(lastMessage); - } - } controller()->sendingAnimation().appendSending( data.messageSendingFrom); const auto localId = data.messageSendingFrom.localId; @@ -5089,13 +5083,6 @@ void HistoryWidget::sendVoice(const VoiceToSend &data) { } void HistoryWidget::send(Api::SendOptions options) { - const auto &ghost = AyuSettings::ghost(&controller()->session()); - - auto lastMessage = _history->lastMessage(); - if (!ghost.sendReadMessages() && ghost.markReadAfterAction() && lastMessage) { - readHistory(lastMessage); - } - if (!_history) { return; } else if (_editMsgId) { diff --git a/Telegram/SourceFiles/history/view/history_view_chat_section.cpp b/Telegram/SourceFiles/history/view/history_view_chat_section.cpp index b2d7449e8c..3cabf7927a 100644 --- a/Telegram/SourceFiles/history/view/history_view_chat_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_chat_section.cpp @@ -95,8 +95,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include // AyuGram includes -#include "ayu/ayu_settings.h" -#include "ayu/utils/telegram_helpers.h" #include "ayu/features/message_shot/message_shot.h" #include "base/unixtime.h" @@ -1420,13 +1418,6 @@ void ChatWidget::sendVoice(const ComposeControls::VoiceToSend &data) { } void ChatWidget::send(Api::SendOptions options) { - const auto &ghost = AyuSettings::ghost(&controller()->session()); - - auto lastMessage = _history->lastMessage(); - if (!ghost.sendReadMessages() && ghost.markReadAfterAction() && lastMessage) { - readHistory(lastMessage); - } - if (!options.scheduled && showSlowmodeError()) { return; } diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 824add532d..4bfca8ce57 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -130,6 +130,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include // AyuGram includes +#include "ayu/utils/telegram_helpers.h" #include "styles/style_ayu_icons.h" #include "ayu/ui/context_menu/context_menu.h" #include "ayu/features/forward/ayu_forward.h" @@ -3602,6 +3603,7 @@ base::weak_qptr ShowSendNowMessagesBox( MTP_int(session->scheduledMessages().lookupId(item))); } } + markReadAfterAction(history); session->api().request(MTPmessages_SendScheduledMessages( history->peer->input(), MTP_vector(ids)