mirror of https://github.com/procxx/kepka.git
				
				
				
			Fix field autocomplete in empty chat.
This commit is contained in:
		
							parent
							
								
									35c759c6bc
								
							
						
					
					
						commit
						44c6050bf2
					
				|  | @ -57,7 +57,10 @@ void FieldAutocomplete::paintEvent(QPaintEvent *e) { | |||
| 	p.fillRect(rect(), st::mentionBg); | ||||
| } | ||||
| 
 | ||||
| void FieldAutocomplete::showFiltered(PeerData *peer, QString query, bool addInlineBots) { | ||||
| void FieldAutocomplete::showFiltered( | ||||
| 		not_null<PeerData*> peer, | ||||
| 		QString query, | ||||
| 		bool addInlineBots) { | ||||
| 	_chat = peer->asChat(); | ||||
| 	_user = peer->asUser(); | ||||
| 	_channel = peer->asChannel(); | ||||
|  | @ -105,9 +108,9 @@ void FieldAutocomplete::showStickers(EmojiPtr emoji) { | |||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	_chat = 0; | ||||
| 	_user = 0; | ||||
| 	_channel = 0; | ||||
| 	_chat = nullptr; | ||||
| 	_user = nullptr; | ||||
| 	_channel = nullptr; | ||||
| 
 | ||||
| 	updateFiltered(resetScroll); | ||||
| } | ||||
|  |  | |||
|  | @ -32,7 +32,10 @@ public: | |||
| 	FieldAutocomplete(QWidget *parent); | ||||
| 
 | ||||
| 	bool clearFilteredBotCommands(); | ||||
| 	void showFiltered(PeerData *peer, QString query, bool addInlineBots); | ||||
| 	void showFiltered( | ||||
| 		not_null<PeerData*> peer, | ||||
| 		QString query, | ||||
| 		bool addInlineBots); | ||||
| 	void showStickers(EmojiPtr emoji); | ||||
| 	void setBoundings(QRect boundings); | ||||
| 
 | ||||
|  |  | |||
|  | @ -1034,6 +1034,9 @@ void HistoryWidget::onHashtagOrBotCommandInsert( | |||
| } | ||||
| 
 | ||||
| void HistoryWidget::updateInlineBotQuery() { | ||||
| 	if (!_history) { | ||||
| 		return; | ||||
| 	} | ||||
| 	const auto query = ParseInlineBotQuery(_field); | ||||
| 	if (_inlineBotUsername != query.username) { | ||||
| 		_inlineBotUsername = query.username; | ||||
|  | @ -1131,20 +1134,22 @@ void HistoryWidget::setReportSpamStatus(DBIPeerReportSpamStatus status) { | |||
| } | ||||
| 
 | ||||
| void HistoryWidget::updateStickersByEmoji() { | ||||
| 	int len = 0; | ||||
| 	if (!_editMsgId) { | ||||
| 		auto &text = _field->getTextWithTags().text; | ||||
| 		if (auto emoji = Ui::Emoji::Find(text, &len)) { | ||||
| 			if (text.size() > len) { | ||||
| 				len = 0; | ||||
| 			} else { | ||||
| 				_fieldAutocomplete->showStickers(emoji); | ||||
| 	if (!_history) { | ||||
| 		return; | ||||
| 	} | ||||
| 	const auto emoji = [&] { | ||||
| 		if (!_editMsgId) { | ||||
| 			const auto &text = _field->getTextWithTags().text; | ||||
| 			auto length = 0; | ||||
| 			if (const auto emoji = Ui::Emoji::Find(text, &length)) { | ||||
| 				if (text.size() <= length) { | ||||
| 					return emoji; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if (!len) { | ||||
| 		_fieldAutocomplete->showStickers(nullptr); | ||||
| 	} | ||||
| 		return EmojiPtr(nullptr); | ||||
| 	}(); | ||||
| 	_fieldAutocomplete->showStickers(emoji); | ||||
| } | ||||
| 
 | ||||
| void HistoryWidget::onTextChange() { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue