diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp index f21834e10..e86658853 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp @@ -491,17 +491,17 @@ void GifsListWidget::selectInlineResult( const auto preview = Data::VideoPreviewState(media.get()); if (forceSend || (media && preview.loaded())) { auto settings = &AyuSettings::getInstance(); + auto from = messageSendingFrom(); + auto sendGIFCallback = crl::guard(this, [=] + { + _fileChosen.fire({ + .document = document, + .options = options, + .messageSendingFrom = from, + }); + }); if (settings->gifConfirmation) { - auto sendGIFCallback = [=, this] - { - _fileChosen.fire({ - .document = document, - .options = options, - .messageSendingFrom = messageSendingFrom(), - }); - }; - Ui::show(Ui::MakeConfirmBox({ .text = tr::ayu_ConfirmationGIF(), .confirmed = sendGIFCallback, @@ -509,11 +509,7 @@ void GifsListWidget::selectInlineResult( })); } else { - _fileChosen.fire({ - .document = document, - .options = options, - .messageSendingFrom = messageSendingFrom(), - }); + sendGIFCallback(); } } else if (!preview.usingThumbnail()) { if (preview.loading()) { diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index babc4c7e3..47401f4e3 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -1752,37 +1752,27 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) { showStickerSetBox(document); } else { auto settings = &AyuSettings::getInstance(); - if (settings->stickerConfirmation) - { - // it is necessary to store it here, because section & index can be changed by cursor position (guess) - int currentSection = sticker->section; - int currentIndex = sticker->index; - auto sendStickerCallback = [=, this] - { - _chosen.fire({ - .document = document, - .messageSendingFrom = messageSentAnimationInfo( - currentSection, - currentIndex, - document), - }); - }; - - Ui::show(Ui::MakeConfirmBox({ - .text = tr::ayu_ConfirmationSticker(), - .confirmed = sendStickerCallback, - .confirmText = tr::lng_send_button() - })); - } - else + auto from = messageSentAnimationInfo( + sticker->section, + sticker->index, + document); + auto sendStickerCallback = crl::guard(this, [=, this] { _chosen.fire({ - .document = document, - .messageSendingFrom = messageSentAnimationInfo( - sticker->section, - sticker->index, - document), - }); + .document = document, + .messageSendingFrom = from, + }); + }); + + if (settings->stickerConfirmation) { + Ui::show(Ui::MakeConfirmBox({ + .text = tr::ayu_ConfirmationSticker(), + .confirmed = sendStickerCallback, + .confirmText = tr::lng_send_button() + })); + } + else { + sendStickerCallback(); } } } else if (auto set = std::get_if(&pressed)) { diff --git a/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp b/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp index d56b10ffa..771555441 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp @@ -1498,14 +1498,14 @@ void VoiceRecordBar::stopRecording(StopType type) { window()->activateWindow(); const auto duration = Duration(data.samples); - auto settings = &AyuSettings::getInstance(); if (type == StopType::Send) { - if (settings->voiceConfirmation) { - auto sendVoiceCallback = [=, this] - { - _sendVoiceRequests.fire({data.bytes, data.waveform, duration}); - }; + auto settings = &AyuSettings::getInstance(); + auto sendVoiceCallback = crl::guard(this, [=, this] + { + _sendVoiceRequests.fire({data.bytes, data.waveform, duration}); + }); + if (settings->voiceConfirmation) { Ui::show(AyuUi::MakeConfirmBox({ .text = tr::ayu_ConfirmationVoice(), .confirmed = sendVoiceCallback, @@ -1513,7 +1513,7 @@ void VoiceRecordBar::stopRecording(StopType type) { })); } else { - _sendVoiceRequests.fire({data.bytes, data.waveform, duration}); + sendVoiceCallback(); } } else if (type == StopType::Listen) { _listen = std::make_unique( @@ -1585,18 +1585,17 @@ void VoiceRecordBar::requestToSendWithOptions(Api::SendOptions options) { if (isListenState()) { const auto data = _listen->data(); auto settings = &AyuSettings::getInstance(); + auto sendVoiceCallback = crl::guard(this, [=, this] + { + _sendVoiceRequests.fire({ + data->bytes, + data->waveform, + Duration(data->samples), + options + }); + }); if (settings->voiceConfirmation) { - auto sendVoiceCallback = [=, this] - { - _sendVoiceRequests.fire({ - data->bytes, - data->waveform, - Duration(data->samples), - options - }); - }; - Ui::show(AyuUi::MakeConfirmBox({ .text = tr::ayu_ConfirmationVoice(), .confirmed = sendVoiceCallback, @@ -1604,12 +1603,7 @@ void VoiceRecordBar::requestToSendWithOptions(Api::SendOptions options) { })); } else { - _sendVoiceRequests.fire({ - data->bytes, - data->waveform, - Duration(data->samples), - options - }); + sendVoiceCallback(); } } }