mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +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 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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue