Support polls with 12 options.

This commit is contained in:
John Preston 2025-05-27 18:31:47 +04:00
parent d7c964afc5
commit 2a153214f6
4 changed files with 16 additions and 4 deletions

View file

@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/stickers/data_custom_emoji.h"
#include "history/view/history_view_schedule_box.h"
#include "lang/lang_keys.h"
#include "main/main_app_config.h"
#include "main/main_session.h"
#include "menu/menu_send.h"
#include "ui/controls/emoji_button.h"
@ -510,7 +511,8 @@ Options::Options(
}
bool Options::full() const {
return (_list.size() == kMaxOptionsCount);
const auto limit = _controller->session().appConfig().pollOptionsLimit();
return (_list.size() >= limit);
}
bool Options::hasOptions() const {
@ -1028,8 +1030,10 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
setCloseByEscape(!count);
setCloseByOutsideClick(!count);
}) | rpl::map([=](int count) {
return (count < kMaxOptionsCount)
? tr::lng_polls_create_limit(tr::now, lt_count, kMaxOptionsCount - count)
const auto appConfig = &_controller->session().appConfig();
const auto max = appConfig->pollOptionsLimit();
return (count < max)
? tr::lng_polls_create_limit(tr::now, lt_count, max - count)
: tr::lng_polls_create_maximum(tr::now);
}) | rpl::after_next([=] {
container->resizeToWidth(container->widthNoMargins());

View file

@ -75,7 +75,7 @@ struct PollData {
int totalVoters = 0;
int version = 0;
static constexpr auto kMaxOptions = 10;
static constexpr auto kMaxOptions = 32;
private:
bool applyResultToAnswers(

View file

@ -140,6 +140,12 @@ int AppConfig::giftResaleReceiveThousandths() const {
return get<int>(u"stars_stargift_resale_commission_permille"_q, 800);
}
int AppConfig::pollOptionsLimit() const {
return get<int>(
u"poll_answers_max"_q,
_account->mtp().isTestMode() ? 12 : 10);
}
void AppConfig::refresh(bool force) {
if (_requestId || !_api) {
if (force) {

View file

@ -82,6 +82,8 @@ public:
[[nodiscard]] int giftResalePriceMin() const;
[[nodiscard]] int giftResaleReceiveThousandths() const;
[[nodiscard]] int pollOptionsLimit() const;
void refresh(bool force = false);
private: