fix: close confirmation box

This commit is contained in:
ZavaruKitsu 2024-01-26 19:48:41 +03:00
parent b3225af685
commit 1e34bc6b30

View file

@ -43,7 +43,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
// AyuGram includes // AyuGram includes
#include "ayu/ayu_settings.h" #include "ayu/ayu_settings.h"
#include "boxes/abstract_box.h" #include "boxes/abstract_box.h"
#include "window/window_controller.h"
namespace HistoryView::Controls { namespace HistoryView::Controls {
namespace { namespace {
@ -1713,7 +1713,7 @@ void VoiceRecordBar::stopRecording(StopType type, bool ttlBeforeHide) {
}; };
auto settings = &AyuSettings::getInstance(); auto settings = &AyuSettings::getInstance();
auto sendVoiceCallback = crl::guard(this, [=, this] auto sendVoiceCallback = crl::guard(this, [=, this](Fn<void()> &&close)
{ {
_sendVoiceRequests.fire({ _sendVoiceRequests.fire({
data.bytes, data.bytes,
@ -1721,18 +1721,19 @@ void VoiceRecordBar::stopRecording(StopType type, bool ttlBeforeHide) {
duration, duration,
options, options,
}); });
close();
}); });
if (settings->voiceConfirmation) { if (settings->voiceConfirmation) {
Ui::show(Ui::MakeConfirmBox( _show->showBox(Ui::MakeConfirmBox(
{ {
.text = tr::ayu_ConfirmationVoice(), .text = tr::ayu_ConfirmationVoice(),
.confirmed = sendVoiceCallback, .confirmed = std::move(sendVoiceCallback),
.confirmText = tr::lng_send_button() .confirmText = tr::lng_send_button()
})); }));
} }
else { else {
sendVoiceCallback(); sendVoiceCallback([]{});
} }
} else if (type == StopType::Listen) { } else if (type == StopType::Listen) {
_listen = std::make_unique<ListenWrap>( _listen = std::make_unique<ListenWrap>(
@ -1808,7 +1809,7 @@ void VoiceRecordBar::requestToSendWithOptions(Api::SendOptions options) {
} }
auto settings = &AyuSettings::getInstance(); auto settings = &AyuSettings::getInstance();
auto sendVoiceCallback = crl::guard(this, [=, this] auto sendVoiceCallback = crl::guard(this, [=, this](Fn<void()> &&close)
{ {
_sendVoiceRequests.fire({ _sendVoiceRequests.fire({
data->bytes, data->bytes,
@ -1816,18 +1817,19 @@ void VoiceRecordBar::requestToSendWithOptions(Api::SendOptions options) {
Duration(data->samples), Duration(data->samples),
options, options,
}); });
close();
}); });
if (settings->voiceConfirmation) { if (settings->voiceConfirmation) {
Ui::show(Ui::MakeConfirmBox( _show->showBox(Ui::MakeConfirmBox(
{ {
.text = tr::ayu_ConfirmationVoice(), .text = tr::ayu_ConfirmationVoice(),
.confirmed = sendVoiceCallback, .confirmed = std::move(sendVoiceCallback),
.confirmText = tr::lng_send_button() .confirmText = tr::lng_send_button()
})); }));
} }
else { else {
sendVoiceCallback(); sendVoiceCallback([]{});
} }
} }
} }