mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Added ability to schedule polls from section of scheduled messages.
Fixed #7433.
This commit is contained in:
@@ -1059,19 +1059,19 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|
||||
*error &= ~Error::Solution;
|
||||
}
|
||||
};
|
||||
const auto showError = [=](const QString &text) {
|
||||
Ui::Toast::Show(text);
|
||||
const auto showError = [](tr::phrase<> text) {
|
||||
Ui::Toast::Show(text(tr::now));
|
||||
};
|
||||
const auto send = [=](Api::SendOptions sendOptions) {
|
||||
collectError();
|
||||
if (*error & Error::Question) {
|
||||
showError(tr::lng_polls_choose_question(tr::now));
|
||||
showError(tr::lng_polls_choose_question);
|
||||
question->setFocus();
|
||||
} else if (*error & Error::Options) {
|
||||
showError(tr::lng_polls_choose_answers(tr::now));
|
||||
showError(tr::lng_polls_choose_answers);
|
||||
options->focusFirst();
|
||||
} else if (*error & Error::Correct) {
|
||||
showError(tr::lng_polls_choose_correct(tr::now));
|
||||
showError(tr::lng_polls_choose_correct);
|
||||
} else if (*error & Error::Solution) {
|
||||
solution->showError();
|
||||
} else if (!*error) {
|
||||
@@ -1079,9 +1079,7 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|
||||
}
|
||||
};
|
||||
const auto sendSilent = [=] {
|
||||
auto options = Api::SendOptions();
|
||||
options.silent = true;
|
||||
send(options);
|
||||
send({ .silent = true });
|
||||
};
|
||||
const auto sendScheduled = [=] {
|
||||
Ui::show(
|
||||
@@ -1102,13 +1100,18 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|
||||
FocusAtEnd(question);
|
||||
}, lifetime());
|
||||
|
||||
const auto isNormal = (_sendType == Api::SendType::Normal);
|
||||
const auto isScheduled = (_sendType == Api::SendType::Scheduled);
|
||||
|
||||
const auto submit = addButton(
|
||||
tr::lng_polls_create_button(),
|
||||
[=] { send({}); });
|
||||
if (_sendType == Api::SendType::Normal) {
|
||||
isNormal
|
||||
? tr::lng_polls_create_button()
|
||||
: tr::lng_schedule_button(),
|
||||
[=] { isNormal ? send({}) : sendScheduled(); });
|
||||
if (isNormal || isScheduled) {
|
||||
const auto sendMenuType = [=] {
|
||||
collectError();
|
||||
return *error
|
||||
return (*error || isScheduled)
|
||||
? SendMenu::Type::Disabled
|
||||
: SendMenu::Type::Scheduled;
|
||||
};
|
||||
|
Reference in New Issue
Block a user