mirror of https://github.com/procxx/kepka.git
Disable creating public polls in channels.
This commit is contained in:
parent
aac6d0df27
commit
d72d1aabe6
|
@ -712,8 +712,10 @@ void Options::checkLastOption() {
|
|||
CreatePollBox::CreatePollBox(
|
||||
QWidget*,
|
||||
not_null<Main::Session*> session,
|
||||
PublicVotes publicVotes,
|
||||
Api::SendType sendType)
|
||||
: _session(session)
|
||||
, _publicVotes(publicVotes)
|
||||
, _sendType(sendType) {
|
||||
}
|
||||
|
||||
|
@ -813,13 +815,15 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|
|||
AddSkip(container);
|
||||
AddSubsectionTitle(container, tr::lng_polls_create_settings());
|
||||
|
||||
const auto anonymous = container->add(
|
||||
object_ptr<Ui::Checkbox>(
|
||||
container,
|
||||
tr::lng_polls_create_anonymous(tr::now),
|
||||
true,
|
||||
st::defaultCheckbox),
|
||||
st::createPollCheckboxMargin);
|
||||
const auto anonymous = (_publicVotes == PublicVotes::Enabled)
|
||||
? container->add(
|
||||
object_ptr<Ui::Checkbox>(
|
||||
container,
|
||||
tr::lng_polls_create_anonymous(tr::now),
|
||||
true,
|
||||
st::defaultCheckbox),
|
||||
st::createPollCheckboxMargin)
|
||||
: nullptr;
|
||||
const auto multiple = container->add(
|
||||
object_ptr<Ui::Checkbox>(
|
||||
container,
|
||||
|
@ -873,7 +877,9 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|
|||
auto result = PollData(&_session->data(), id);
|
||||
result.question = question->getLastText().trimmed();
|
||||
result.answers = options->toPollAnswers();
|
||||
result.setFlags((anonymous->checked() ? Flag(0) : Flag::PublicVotes)
|
||||
const auto publicVotes = (anonymous && !anonymous->checked());
|
||||
result.setFlags(Flag(0)
|
||||
| (publicVotes ? Flag::PublicVotes : Flag(0))
|
||||
| (multiple->checked() ? Flag::MultiChoice : Flag(0))
|
||||
| (quiz->checked() ? Flag::Quiz : Flag(0)));
|
||||
return result;
|
||||
|
|
|
@ -27,10 +27,15 @@ public:
|
|||
PollData poll;
|
||||
Api::SendOptions options;
|
||||
};
|
||||
enum class PublicVotes {
|
||||
Enabled,
|
||||
Disabled,
|
||||
};
|
||||
|
||||
CreatePollBox(
|
||||
QWidget*,
|
||||
not_null<Main::Session*> session,
|
||||
PublicVotes publicVotes,
|
||||
Api::SendType sendType);
|
||||
|
||||
rpl::producer<Result> submitRequests() const;
|
||||
|
@ -47,6 +52,7 @@ private:
|
|||
not_null<Ui::VerticalLayout*> container);
|
||||
|
||||
const not_null<Main::Session*> _session;
|
||||
const PublicVotes _publicVotes = PublicVotes();
|
||||
const Api::SendType _sendType = Api::SendType();
|
||||
Fn<void()> _setInnerFocus;
|
||||
Fn<rpl::producer<bool>()> _dataIsValidValue;
|
||||
|
|
|
@ -710,6 +710,9 @@ void PeerMenuShareContactBox(
|
|||
void PeerMenuCreatePoll(not_null<PeerData*> peer) {
|
||||
const auto box = Ui::show(Box<CreatePollBox>(
|
||||
&peer->session(),
|
||||
((peer->isChannel() && !peer->isMegagroup())
|
||||
? CreatePollBox::PublicVotes::Disabled
|
||||
: CreatePollBox::PublicVotes::Enabled),
|
||||
Api::SendType::Normal));
|
||||
const auto lock = box->lifetime().make_state<bool>(false);
|
||||
box->submitRequests(
|
||||
|
|
Loading…
Reference in New Issue