Send updateSpeechRecognitionTrial when it resets.
This commit is contained in:
parent
40142a45a0
commit
4d98fd1a44
@ -134,6 +134,7 @@ void TranscriptionManager::load_trial_parameters() {
|
||||
}
|
||||
}
|
||||
send_update_speech_recognition_trial();
|
||||
set_speech_recognition_trial_timeout();
|
||||
}
|
||||
|
||||
void TranscriptionManager::save_trial_parameters() {
|
||||
@ -162,9 +163,37 @@ void TranscriptionManager::set_trial_parameters(TrialParameters new_trial_parame
|
||||
|
||||
trial_parameters_ = std::move(new_trial_parameters);
|
||||
send_update_speech_recognition_trial();
|
||||
set_speech_recognition_trial_timeout();
|
||||
save_trial_parameters();
|
||||
}
|
||||
|
||||
void TranscriptionManager::set_speech_recognition_trial_timeout() {
|
||||
if (trial_parameters_.next_reset_date_ == 0) {
|
||||
trial_parameters_timeout_.cancel_timeout();
|
||||
} else {
|
||||
trial_parameters_timeout_.set_callback(std::move(trial_parameters_timeout_static));
|
||||
trial_parameters_timeout_.set_callback_data(static_cast<void *>(td_));
|
||||
trial_parameters_timeout_.set_timeout_in(trial_parameters_.next_reset_date_ - G()->unix_time() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void TranscriptionManager::trial_parameters_timeout_static(void *td) {
|
||||
if (G()->close_flag()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CHECK(td != nullptr);
|
||||
static_cast<Td *>(td)->transcription_manager_->on_trial_parameters_timeout();
|
||||
}
|
||||
|
||||
void TranscriptionManager::on_trial_parameters_timeout() {
|
||||
if (!td_->auth_manager_->is_authorized()) {
|
||||
return;
|
||||
}
|
||||
CHECK(!td_->auth_manager_->is_bot());
|
||||
set_trial_parameters(trial_parameters_);
|
||||
}
|
||||
|
||||
void TranscriptionManager::send_update_speech_recognition_trial() const {
|
||||
send_closure(G()->td(), &Td::send_update, get_update_speech_recognition_trial_object());
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "td/actor/actor.h"
|
||||
#include "td/actor/MultiTimeout.h"
|
||||
#include "td/actor/Timeout.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/FlatHashMap.h"
|
||||
@ -88,6 +89,12 @@ class TranscriptionManager final : public Actor {
|
||||
|
||||
void set_trial_parameters(TrialParameters new_trial_parameters);
|
||||
|
||||
void set_speech_recognition_trial_timeout();
|
||||
|
||||
static void trial_parameters_timeout_static(void *td);
|
||||
|
||||
void on_trial_parameters_timeout();
|
||||
|
||||
void save_trial_parameters();
|
||||
|
||||
void send_update_speech_recognition_trial() const;
|
||||
@ -116,6 +123,7 @@ class TranscriptionManager final : public Actor {
|
||||
ActorShared<> parent_;
|
||||
|
||||
TrialParameters trial_parameters_;
|
||||
Timeout trial_parameters_timeout_;
|
||||
|
||||
FlatHashMap<int64, TranscribedAudioHandler> pending_audio_transcriptions_;
|
||||
MultiTimeout pending_audio_transcription_timeout_{"PendingAudioTranscriptionTimeout"};
|
||||
|
Loading…
Reference in New Issue
Block a user