2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Support creating polls from bot keyboards.

This commit is contained in:
John Preston
2020-01-15 16:30:29 +03:00
parent c3aa2abe11
commit d0597407d8
10 changed files with 104 additions and 29 deletions

View File

@@ -413,6 +413,11 @@ void Filler::addUserActions(not_null<UserData*> user) {
tr::lng_profile_invite_to_group(tr::now),
[=] { AddBotToGroup::Start(controller, user); });
}
if (user->canSendPolls()) {
_addAction(
tr::lng_polls_create(tr::now),
[=] { PeerMenuCreatePoll(user); });
}
if (user->canExportChatHistory()) {
_addAction(
tr::lng_profile_export_chat(tr::now),
@@ -707,12 +712,18 @@ void PeerMenuShareContactBox(
}));
}
void PeerMenuCreatePoll(not_null<PeerData*> peer) {
void PeerMenuCreatePoll(
not_null<PeerData*> peer,
PollData::Flags chosen,
PollData::Flags disabled) {
if (peer->isChannel() && !peer->isMegagroup()) {
chosen &= ~PollData::Flag::PublicVotes;
disabled |= PollData::Flag::PublicVotes;
}
const auto box = Ui::show(Box<CreatePollBox>(
&peer->session(),
((peer->isChannel() && !peer->isMegagroup())
? CreatePollBox::PublicVotes::Disabled
: CreatePollBox::PublicVotes::Enabled),
chosen,
disabled,
Api::SendType::Normal));
const auto lock = box->lifetime().make_state<bool>(false);
box->submitRequests(