From b01d7ea5b985b9aadb46ebae19391873b481199a Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 24 Oct 2024 12:38:16 +0400 Subject: [PATCH] Show recording init errors. --- .../SourceFiles/history/history_widget.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 3cb5398574..6036cd685f 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1057,6 +1057,24 @@ void HistoryWidget::initVoiceRecordBar() { _cornerButtons.updateUnreadThingsVisibility(); }, lifetime()); + _voiceRecordBar->errors( + ) | rpl::start_with_next([=](::Media::Capture::Error error) { + using Error = ::Media::Capture::Error; + switch (error) { + case Error::AudioInit: + case Error::AudioTimeout: + controller()->showToast(tr::lng_record_audio_problem(tr::now)); + break; + case Error::VideoInit: + case Error::VideoTimeout: + controller()->showToast(tr::lng_record_video_problem(tr::now)); + break; + default: + controller()->showToast(u"Unknown error."_q); + break; + } + }, lifetime()); + _voiceRecordBar->updateSendButtonTypeRequests( ) | rpl::start_with_next([=] { updateSendButtonType();