mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix password request box closing in bot button callback.
This commit is contained in:
parent
fdb29a756a
commit
ff352d7647
1 changed files with 18 additions and 5 deletions
|
@ -45,6 +45,7 @@ void SendBotCallbackData(
|
||||||
int row,
|
int row,
|
||||||
int column,
|
int column,
|
||||||
std::optional<Core::CloudPasswordResult> password,
|
std::optional<Core::CloudPasswordResult> password,
|
||||||
|
Fn<void()> done = nullptr,
|
||||||
Fn<void(const QString &)> handleError = nullptr) {
|
Fn<void(const QString &)> handleError = nullptr) {
|
||||||
if (!item->isRegular()) {
|
if (!item->isRegular()) {
|
||||||
return;
|
return;
|
||||||
|
@ -92,6 +93,11 @@ void SendBotCallbackData(
|
||||||
MTP_bytes(sendData),
|
MTP_bytes(sendData),
|
||||||
password ? password->result : MTP_inputCheckPasswordEmpty()
|
password ? password->result : MTP_inputCheckPasswordEmpty()
|
||||||
)).done([=](const MTPmessages_BotCallbackAnswer &result) {
|
)).done([=](const MTPmessages_BotCallbackAnswer &result) {
|
||||||
|
const auto guard = gsl::finally([&] {
|
||||||
|
if (done) {
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
});
|
||||||
const auto item = owner->message(fullId);
|
const auto item = owner->message(fullId);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
return;
|
return;
|
||||||
|
@ -139,6 +145,11 @@ void SendBotCallbackData(
|
||||||
show->hideLayer();
|
show->hideLayer();
|
||||||
}
|
}
|
||||||
}).fail([=](const MTP::Error &error) {
|
}).fail([=](const MTP::Error &error) {
|
||||||
|
const auto guard = gsl::finally([&] {
|
||||||
|
if (handleError) {
|
||||||
|
handleError(error.type());
|
||||||
|
}
|
||||||
|
});
|
||||||
const auto item = owner->message(fullId);
|
const auto item = owner->message(fullId);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
return;
|
return;
|
||||||
|
@ -148,9 +159,6 @@ void SendBotCallbackData(
|
||||||
button->requestId = 0;
|
button->requestId = 0;
|
||||||
owner->requestItemRepaint(item);
|
owner->requestItemRepaint(item);
|
||||||
}
|
}
|
||||||
if (handleError) {
|
|
||||||
handleError(error.type());
|
|
||||||
}
|
|
||||||
}).send();
|
}).send();
|
||||||
|
|
||||||
session->changes().messageUpdated(
|
session->changes().messageUpdated(
|
||||||
|
@ -204,7 +212,8 @@ void SendBotCallbackDataWithPassword(
|
||||||
api->cloudPassword().reload();
|
api->cloudPassword().reload();
|
||||||
const auto weak = base::make_weak(controller);
|
const auto weak = base::make_weak(controller);
|
||||||
const auto show = std::make_shared<Window::Show>(controller);
|
const auto show = std::make_shared<Window::Show>(controller);
|
||||||
SendBotCallbackData(controller, item, row, column, std::nullopt, [=](const QString &error) {
|
SendBotCallbackData(controller, item, row, column, {}, {}, [=](
|
||||||
|
const QString &error) {
|
||||||
auto box = PrePasswordErrorBox(
|
auto box = PrePasswordErrorBox(
|
||||||
error,
|
error,
|
||||||
session,
|
session,
|
||||||
|
@ -250,7 +259,11 @@ void SendBotCallbackDataWithPassword(
|
||||||
if (!strongController) {
|
if (!strongController) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SendBotCallbackData(strongController, item, row, column, result, [=](const QString &error) {
|
SendBotCallbackData(strongController, item, row, column, result, [=] {
|
||||||
|
if (*box) {
|
||||||
|
(*box)->closeBox();
|
||||||
|
}
|
||||||
|
}, [=](const QString &error) {
|
||||||
if (*box) {
|
if (*box) {
|
||||||
(*box)->handleCustomCheckError(error);
|
(*box)->handleCustomCheckError(error);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue