2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45: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(

View File

@@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "data/data_poll.h"
class History;
namespace Ui {
@@ -58,7 +60,10 @@ void PeerMenuAddChannelMembers(
not_null<Window::SessionNavigation*> navigation,
not_null<ChannelData*> channel);
//void PeerMenuUngroupFeed(not_null<Data::Feed*> feed); // #feed
void PeerMenuCreatePoll(not_null<PeerData*> peer);
void PeerMenuCreatePoll(
not_null<PeerData*> peer,
PollData::Flags chosen = PollData::Flags(),
PollData::Flags disabled = PollData::Flags());
void PeerMenuBlockUserBox(
not_null<Ui::GenericBox*> box,
not_null<Window::Controller*> window,