Fixed draft applying while recording voice message in HistoryWidget.

Relevant commit: d15a5c9bdc.
This commit is contained in:
23rd 2020-12-10 08:39:03 +03:00 committed by John Preston
parent 1b624d67b8
commit de20ff05eb
3 changed files with 14 additions and 1 deletions

View file

@ -820,6 +820,13 @@ void HistoryWidget::initVoiceRecordBar() {
_scroll->viewportEvent(e);
}, lifetime());
_voiceRecordBar->shownValue(
) | rpl::start_with_next([=](bool shown) {
if (!shown) {
applyDraft();
}
}, lifetime());
_voiceRecordBar->hideFast();
}
@ -1621,7 +1628,8 @@ void HistoryWidget::applyDraft(FieldHistoryAction fieldHistoryAction) {
: _history->localEditDraft()
? _history->localEditDraft()
: _history->localDraft();
auto fieldAvailable = canWriteMessage();
auto fieldAvailable = canWriteMessage()
&& !_voiceRecordBar->preventDraftApply();
if (!draft || (!_history->localEditDraft() && !fieldAvailable)) {
auto fieldWillBeHiddenAfterEdit = (!fieldAvailable && _editMsgId != 0);
clearFieldText(0, fieldHistoryAction);

View file

@ -1414,6 +1414,10 @@ bool VoiceRecordBar::isRecording() const {
return _recording.current();
}
bool VoiceRecordBar::preventDraftApply() const {
return isRecording() || isListenState();
}
void VoiceRecordBar::hideAnimated() {
if (isHidden()) {
return;

View file

@ -72,6 +72,7 @@ public:
[[nodiscard]] bool isRecording() const;
[[nodiscard]] bool isLockPresent() const;
[[nodiscard]] bool isListenState() const;
[[nodiscard]] bool preventDraftApply() const;
private:
enum class StopType {