mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Removed item for poll creation from menu when it is impossible.
This commit is contained in:
parent
363c191a6e
commit
aff2be605e
1 changed files with 28 additions and 0 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue