Delegated responsibility for clearing listen state to sections.

This commit is contained in:
23rd 2020-11-19 18:11:09 +03:00 committed by John Preston
parent b1b01385d0
commit 0a0dcb9054
7 changed files with 19 additions and 2 deletions

View file

@ -797,6 +797,7 @@ void HistoryWidget::initVoiceRecordBar() {
data.waveform, data.waveform,
data.duration, data.duration,
action); action);
_voiceRecordBar->clearListenState();
}, lifetime()); }, lifetime());
_voiceRecordBar->lockShowStarts( _voiceRecordBar->lockShowStarts(

View file

@ -1018,6 +1018,10 @@ bool ComposeControls::showRecordButton() const {
&& !isEditingMessage(); && !isEditingMessage();
} }
void ComposeControls::clearListenState() {
_voiceRecordBar->clearListenState();
}
void ComposeControls::drawRestrictedWrite(Painter &p, const QString &error) { void ComposeControls::drawRestrictedWrite(Painter &p, const QString &error) {
p.fillRect(_writeRestricted->rect(), st::historyReplyBg); p.fillRect(_writeRestricted->rect(), st::historyReplyBg);

View file

@ -152,6 +152,7 @@ public:
void setText(const TextWithTags &text); void setText(const TextWithTags &text);
void clear(); void clear();
void hidePanelsAnimated(); void hidePanelsAnimated();
void clearListenState();
[[nodiscard]] rpl::producer<bool> lockShowStarts() const; [[nodiscard]] rpl::producer<bool> lockShowStarts() const;
[[nodiscard]] bool isLockPresent() const; [[nodiscard]] bool isLockPresent() const;

View file

@ -1399,7 +1399,6 @@ void VoiceRecordBar::requestToSendWithOptions(Api::SendOptions options) {
data->waveform, data->waveform,
Duration(data->samples), Duration(data->samples),
options }); options });
hideAnimated();
} }
} }
@ -1416,6 +1415,9 @@ bool VoiceRecordBar::isRecording() const {
} }
void VoiceRecordBar::hideAnimated() { void VoiceRecordBar::hideAnimated() {
if (isHidden()) {
return;
}
visibilityAnimate(false, [=] { hide(); }); visibilityAnimate(false, [=] { hide(); });
} }
@ -1455,6 +1457,12 @@ float64 VoiceRecordBar::activeAnimationRatio() const {
return _activeAnimation.value(_inField.current() ? 1. : 0.); return _activeAnimation.value(_inField.current() ? 1. : 0.);
} }
void VoiceRecordBar::clearListenState() {
if (isListenState()) {
hideAnimated();
}
}
float64 VoiceRecordBar::showAnimationRatio() const { float64 VoiceRecordBar::showAnimationRatio() const {
// There is no reason to set the final value to zero, // There is no reason to set the final value to zero,
// because at zero this widget is hidden. // because at zero this widget is hidden.

View file

@ -49,7 +49,9 @@ public:
void startRecording(); void startRecording();
void finishAnimating(); void finishAnimating();
void hideAnimated();
void hideFast(); void hideFast();
void clearListenState();
void orderControls(); void orderControls();
@ -102,7 +104,6 @@ private:
bool isTypeRecord() const; bool isTypeRecord() const;
bool hasDuration() const; bool hasDuration() const;
void hideAnimated();
void finish(); void finish();
void activeAnimate(bool active); void activeAnimate(bool active);

View file

@ -890,6 +890,7 @@ void RepliesWidget::sendVoice(ComposeControls::VoiceToSend &&data) {
std::move(action)); std::move(action));
_composeControls->cancelReplyMessage(); _composeControls->cancelReplyMessage();
_composeControls->clearListenState();
finishSending(); finishSending();
} }

View file

@ -573,6 +573,7 @@ void ScheduledWidget::sendVoice(
auto action = Api::SendAction(_history); auto action = Api::SendAction(_history);
action.options = options; action.options = options;
session().api().sendVoiceMessage(bytes, waveform, duration, action); session().api().sendVoiceMessage(bytes, waveform, duration, action);
_composeControls->clearListenState();
} }
void ScheduledWidget::edit( void ScheduledWidget::edit(