From fe4b853393f1cf93874af35952e5f4a9e86d925f Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 13 Mar 2024 21:29:46 +0300 Subject: [PATCH] Improved section of scheduled messages when forum opened in flat mode. --- .../history/view/history_view_context_menu.cpp | 6 ++++-- .../SourceFiles/history/view/history_view_element.h | 1 + .../SourceFiles/history/view/history_view_message.cpp | 10 +++++----- .../history/view/history_view_scheduled_section.cpp | 11 ++++++++--- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index 09c3b89f9..5a7852b82 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -104,7 +104,8 @@ bool HasEditMessageAction( || !request.selectedItems.empty() || (context != Context::History && context != Context::Replies - && context != Context::ShortcutMessages)) { + && context != Context::ShortcutMessages + && context != Context::ScheduledTopic)) { return false; } const auto peer = item->history()->peer; @@ -1340,7 +1341,8 @@ void AddPollActions( } if ((context != Context::History) && (context != Context::Replies) - && (context != Context::Pinned)) { + && (context != Context::Pinned) + && (context != Context::ScheduledTopic)) { return; } if (poll->closed()) { diff --git a/Telegram/SourceFiles/history/view/history_view_element.h b/Telegram/SourceFiles/history/view/history_view_element.h index 5a6ea07d6..f47937516 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.h +++ b/Telegram/SourceFiles/history/view/history_view_element.h @@ -60,6 +60,7 @@ enum class Context : char { SavedSublist, TTLViewer, ShortcutMessages, + ScheduledTopic, }; enum class OnlyEmojiAndSpaces : char { diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 18c3dc57a..2e8f79f30 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -861,9 +861,7 @@ QSize Message::performCountOptimalSize() { void Message::refreshTopicButton() { const auto item = data(); - if (isAttachedToPrevious() - || (context() != Context::History) - || item->isScheduled()) { + if (isAttachedToPrevious() || context() != Context::History) { _topicButton = nullptr; } else if (const auto topic = item->topic()) { if (!_topicButton) { @@ -2044,7 +2042,8 @@ bool Message::hasFromPhoto() const { case Context::TTLViewer: case Context::Pinned: case Context::Replies: - case Context::SavedSublist: { + case Context::SavedSublist: + case Context::ScheduledTopic: { const auto item = data(); if (item->isPost()) { return false; @@ -3243,7 +3242,8 @@ bool Message::hasFromName() const { case Context::TTLViewer: case Context::Pinned: case Context::Replies: - case Context::SavedSublist: { + case Context::SavedSublist: + case Context::ScheduledTopic: { const auto item = data(); const auto peer = item->history()->peer; if (hasOutLayout() && !item->from()->isChannel()) { diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index c93b149eb..2a6328b38 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -252,7 +252,8 @@ void ScheduledWidget::setupComposeControls() { & ~ChatRestriction::SendPolls; const auto canSendAnything = Data::CanSendAnyOf( _history->peer, - allWithoutPolls); + allWithoutPolls, + false); const auto restriction = Data::RestrictionError( _history->peer, ChatRestriction::SendOther); @@ -650,7 +651,11 @@ void ScheduledWidget::send() { const auto error = GetErrorTextForSending( _history->peer, { - .topicRootId = _forumTopic ? _forumTopic->topicRootId() : MsgId(), + .topicRootId = _forumTopic + ? _forumTopic->topicRootId() + : history()->isForum() + ? MsgId(1) + : MsgId(), .forward = nullptr, .text = &textWithTags, .ignoreSlowmodeCountdown = true, @@ -1143,7 +1148,7 @@ QRect ScheduledWidget::floatPlayerAvailableRect() { } Context ScheduledWidget::listContext() { - return Context::History; + return _forumTopic ? Context::ScheduledTopic : Context::History; } bool ScheduledWidget::listScrollTo(int top, bool syntetic) {