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

Allow to schedule created polls.

This commit is contained in:
John Preston
2019-08-20 16:21:10 +03:00
parent 8eac2dcb78
commit ef7087348a
17 changed files with 243 additions and 115 deletions

View File

@@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwidget.h"
#include "mainwindow.h"
#include "observer_peer.h"
#include "api/api_common.h"
#include "history/history.h"
#include "history/history_item.h"
#include "window/window_session_controller.h"
@@ -700,14 +701,17 @@ void PeerMenuShareContactBox(
}
void PeerMenuCreatePoll(not_null<PeerData*> peer) {
const auto box = Ui::show(Box<CreatePollBox>(&peer->session()));
const auto box = Ui::show(Box<CreatePollBox>(
&peer->session(),
Api::SendType::Normal));
const auto lock = box->lifetime().make_state<bool>(false);
box->submitRequests(
) | rpl::start_with_next([=](const PollData &result) {
) | rpl::start_with_next([=](const CreatePollBox::Result &result) {
if (std::exchange(*lock, true)) {
return;
}
auto action = Api::SendAction(peer->owner().history(peer));
action.options = result.options;
if (const auto id = App::main()->currentReplyToIdFor(action.history)) {
action.replyTo = id;
}
@@ -715,7 +719,7 @@ void PeerMenuCreatePoll(not_null<PeerData*> peer) {
action.clearDraft = localDraft->textWithTags.text.isEmpty();
}
const auto api = &peer->session().api();
api->createPoll(result, action, crl::guard(box, [=] {
api->createPoll(result.poll, action, crl::guard(box, [=] {
box->closeBox();
}), crl::guard(box, [=](const RPCError &error) {
*lock = false;