Fixed draft applying while recording voice message in HistoryWidget.
Relevant commit: d15a5c9bdc.
			
			
This commit is contained in:
		
							parent
							
								
									1b624d67b8
								
							
						
					
					
						commit
						de20ff05eb
					
				
					 3 changed files with 14 additions and 1 deletions
				
			
		| 
						 | 
					@ -820,6 +820,13 @@ void HistoryWidget::initVoiceRecordBar() {
 | 
				
			||||||
		_scroll->viewportEvent(e);
 | 
							_scroll->viewportEvent(e);
 | 
				
			||||||
	}, lifetime());
 | 
						}, lifetime());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_voiceRecordBar->shownValue(
 | 
				
			||||||
 | 
						) | rpl::start_with_next([=](bool shown) {
 | 
				
			||||||
 | 
							if (!shown) {
 | 
				
			||||||
 | 
								applyDraft();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}, lifetime());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_voiceRecordBar->hideFast();
 | 
						_voiceRecordBar->hideFast();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1621,7 +1628,8 @@ void HistoryWidget::applyDraft(FieldHistoryAction fieldHistoryAction) {
 | 
				
			||||||
		: _history->localEditDraft()
 | 
							: _history->localEditDraft()
 | 
				
			||||||
		? _history->localEditDraft()
 | 
							? _history->localEditDraft()
 | 
				
			||||||
		: _history->localDraft();
 | 
							: _history->localDraft();
 | 
				
			||||||
	auto fieldAvailable = canWriteMessage();
 | 
						auto fieldAvailable = canWriteMessage()
 | 
				
			||||||
 | 
							&& !_voiceRecordBar->preventDraftApply();
 | 
				
			||||||
	if (!draft || (!_history->localEditDraft() && !fieldAvailable)) {
 | 
						if (!draft || (!_history->localEditDraft() && !fieldAvailable)) {
 | 
				
			||||||
		auto fieldWillBeHiddenAfterEdit = (!fieldAvailable && _editMsgId != 0);
 | 
							auto fieldWillBeHiddenAfterEdit = (!fieldAvailable && _editMsgId != 0);
 | 
				
			||||||
		clearFieldText(0, fieldHistoryAction);
 | 
							clearFieldText(0, fieldHistoryAction);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1414,6 +1414,10 @@ bool VoiceRecordBar::isRecording() const {
 | 
				
			||||||
	return _recording.current();
 | 
						return _recording.current();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool VoiceRecordBar::preventDraftApply() const {
 | 
				
			||||||
 | 
						return isRecording() || isListenState();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void VoiceRecordBar::hideAnimated() {
 | 
					void VoiceRecordBar::hideAnimated() {
 | 
				
			||||||
	if (isHidden()) {
 | 
						if (isHidden()) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -72,6 +72,7 @@ public:
 | 
				
			||||||
	[[nodiscard]] bool isRecording() const;
 | 
						[[nodiscard]] bool isRecording() const;
 | 
				
			||||||
	[[nodiscard]] bool isLockPresent() const;
 | 
						[[nodiscard]] bool isLockPresent() const;
 | 
				
			||||||
	[[nodiscard]] bool isListenState() const;
 | 
						[[nodiscard]] bool isListenState() const;
 | 
				
			||||||
 | 
						[[nodiscard]] bool preventDraftApply() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	enum class StopType {
 | 
						enum class StopType {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue