Lock poll creating.

Fixes #5504.
This commit is contained in:
John Preston 2018-12-23 20:47:00 +04:00
parent 4d495b8d7c
commit e397f72eb2

View File

@ -629,12 +629,17 @@ void PeerMenuShareContactBox(not_null<UserData*> user) {
void PeerMenuCreatePoll(not_null<PeerData*> peer) {
const auto box = Ui::show(Box<CreatePollBox>());
const auto lock = box->lifetime().make_state<bool>(false);
box->submitRequests(
) | rpl::start_with_next([=](const PollData &result) {
if (std::exchange(*lock, true)) {
return;
}
const auto options = ApiWrap::SendOptions(App::history(peer));
Auth().api().createPoll(result, options, crl::guard(box, [=] {
box->closeBox();
}), crl::guard(box, [=](const RPCError &error) {
*lock = false;
box->submitFailed(lang(lng_attach_failed));
}));
}, box->lifetime());