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.duration,
action);
_voiceRecordBar->clearListenState();
}, lifetime());
_voiceRecordBar->lockShowStarts(

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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