mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-03 16:05:57 +00:00
@@ -629,12 +629,17 @@ void PeerMenuShareContactBox(not_null<UserData*> user) {
|
|||||||
|
|
||||||
void PeerMenuCreatePoll(not_null<PeerData*> peer) {
|
void PeerMenuCreatePoll(not_null<PeerData*> peer) {
|
||||||
const auto box = Ui::show(Box<CreatePollBox>());
|
const auto box = Ui::show(Box<CreatePollBox>());
|
||||||
|
const auto lock = box->lifetime().make_state<bool>(false);
|
||||||
box->submitRequests(
|
box->submitRequests(
|
||||||
) | rpl::start_with_next([=](const PollData &result) {
|
) | rpl::start_with_next([=](const PollData &result) {
|
||||||
|
if (std::exchange(*lock, true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const auto options = ApiWrap::SendOptions(App::history(peer));
|
const auto options = ApiWrap::SendOptions(App::history(peer));
|
||||||
Auth().api().createPoll(result, options, crl::guard(box, [=] {
|
Auth().api().createPoll(result, options, crl::guard(box, [=] {
|
||||||
box->closeBox();
|
box->closeBox();
|
||||||
}), crl::guard(box, [=](const RPCError &error) {
|
}), crl::guard(box, [=](const RPCError &error) {
|
||||||
|
*lock = false;
|
||||||
box->submitFailed(lang(lng_attach_failed));
|
box->submitFailed(lang(lng_attach_failed));
|
||||||
}));
|
}));
|
||||||
}, box->lifetime());
|
}, box->lifetime());
|
||||||
|
Reference in New Issue
Block a user