2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-06 17:35:36 +00:00

Fix password request box closing in bot button callback.

This commit is contained in:
John Preston
2022-11-02 18:36:26 +04:00
parent fdb29a756a
commit ff352d7647

View File

@@ -45,6 +45,7 @@ void SendBotCallbackData(
int row,
int column,
std::optional<Core::CloudPasswordResult> password,
Fn<void()> done = nullptr,
Fn<void(const QString &)> handleError = nullptr) {
if (!item->isRegular()) {
return;
@@ -92,6 +93,11 @@ void SendBotCallbackData(
MTP_bytes(sendData),
password ? password->result : MTP_inputCheckPasswordEmpty()
)).done([=](const MTPmessages_BotCallbackAnswer &result) {
const auto guard = gsl::finally([&] {
if (done) {
done();
}
});
const auto item = owner->message(fullId);
if (!item) {
return;
@@ -139,6 +145,11 @@ void SendBotCallbackData(
show->hideLayer();
}
}).fail([=](const MTP::Error &error) {
const auto guard = gsl::finally([&] {
if (handleError) {
handleError(error.type());
}
});
const auto item = owner->message(fullId);
if (!item) {
return;
@@ -148,9 +159,6 @@ void SendBotCallbackData(
button->requestId = 0;
owner->requestItemRepaint(item);
}
if (handleError) {
handleError(error.type());
}
}).send();
session->changes().messageUpdated(
@@ -204,7 +212,8 @@ void SendBotCallbackDataWithPassword(
api->cloudPassword().reload();
const auto weak = base::make_weak(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(
error,
session,
@@ -250,7 +259,11 @@ void SendBotCallbackDataWithPassword(
if (!strongController) {
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) {
(*box)->handleCustomCheckError(error);
}