Handle MSG_VOICE_TOO_LONG for voice messages.

This commit is contained in:
John Preston 2022-06-06 18:04:27 +04:00
parent 719190d570
commit f586ea3a75
4 changed files with 11 additions and 3 deletions

View file

@ -2654,6 +2654,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_audio_player_reverse" = "Reverse order"; "lng_audio_player_reverse" = "Reverse order";
"lng_audio_player_shuffle" = "Shuffle"; "lng_audio_player_shuffle" = "Shuffle";
"lng_audio_transcribe_long" = "This voice message is too long.";
"lng_rights_edit_admin" = "Manage permissions"; "lng_rights_edit_admin" = "Manage permissions";
"lng_rights_edit_admin_header" = "What can this admin do?"; "lng_rights_edit_admin_header" = "What can this admin do?";

View file

@ -78,12 +78,14 @@ void Transcribes::load(not_null<HistoryItem*> item) {
_session->data().requestItemResize(item); _session->data().requestItemResize(item);
} }
}); });
}).fail([=] { }).fail([=](const MTP::Error &error) {
auto &entry = _map[id]; auto &entry = _map[id];
entry.requestId = 0; entry.requestId = 0;
entry.pending = false; entry.pending = false;
entry.failed = true; entry.failed = true;
if (const auto item = _session->data().message(id)) { if (error.type() == qstr("MSG_VOICE_TOO_LONG")) {
entry.toolong = true;
} else if (const auto item = _session->data().message(id)) {
_session->data().requestItemResize(item); _session->data().requestItemResize(item);
} }
}).send(); }).send();

View file

@ -25,6 +25,7 @@ public:
QString result; QString result;
bool shown = false; bool shown = false;
bool failed = false; bool failed = false;
bool toolong = false;
bool pending = false; bool pending = false;
mtpRequestId requestId = 0; mtpRequestId requestId = 0;
}; };

View file

@ -256,9 +256,13 @@ QSize Document::countOptimalSize() {
update); update);
auto text = (entry.requestId || !entry.shown) auto text = (entry.requestId || !entry.shown)
? TextWithEntities() ? TextWithEntities()
: entry.toolong
? Ui::Text::Italic(tr::lng_audio_transcribe_long(tr::now))
: entry.failed : entry.failed
? Ui::Text::Italic(tr::lng_attach_failed(tr::now)) ? Ui::Text::Italic(tr::lng_attach_failed(tr::now))
: TextWithEntities{ entry.result }; : TextWithEntities{
entry.result + (entry.pending ? " [...]" : ""),
};
voice->transcribe->setOpened(!text.empty(), update); voice->transcribe->setOpened(!text.empty(), update);
if (text.empty()) { if (text.empty()) {
voice->transcribeText = {}; voice->transcribeText = {};