From aff2be605e09288a67b00a81ed04c62a15bc37fd Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 26 Apr 2024 18:46:44 +0300 Subject: [PATCH] Removed item for poll creation from menu when it is impossible. --- .../SourceFiles/window/window_peer_menu.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 6860d3b0a8..f3749d6229 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -1085,6 +1085,34 @@ void Filler::addViewStatistics() { } void Filler::addCreatePoll() { + const auto isJoinChannel = [&] { + if (_request.section != Section::Replies) { + if (const auto c = _peer->asChannel(); c && !c->amIn()) { + return true; + } + } + return false; + }(); + const auto isBotStart = [&] { + const auto user = _peer ? _peer->asUser() : nullptr; + if (!user || !user->isBot()) { + return false; + } else if (!user->botInfo->startToken.isEmpty()) { + return true; + } + const auto history = _peer->owner().history(_peer); + if (history && history->isEmpty() && !history->lastMessage()) { + return true; + } + return false; + }(); + const auto isBlocked = [&] { + return _peer && _peer->isUser() && _peer->asUser()->isBlocked(); + }(); + if (isBlocked || isJoinChannel || isBotStart) { + return; + } + const auto can = _topic ? Data::CanSend(_topic, ChatRestriction::SendPolls) : _peer->canCreatePolls();