mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Improved search of emoji from emoji list widget.
This commit is contained in:
@@ -670,12 +670,13 @@ void EmojiListWidget::applyNextSearchQuery() {
|
||||
}
|
||||
const auto guard = gsl::finally([&] { finish(); });
|
||||
auto plain = collectPlainSearchResults();
|
||||
if (_searchEmoji == _searchEmojiPrevious) {
|
||||
return;
|
||||
}
|
||||
_searchEmoticon = QString();
|
||||
for (const auto emoji : plain) {
|
||||
_searchEmoticon += emoji->text();
|
||||
{
|
||||
auto exactSet = base::flat_set<EmojiPtr>();
|
||||
const auto exact = SearchEmoji(_searchQuery, exactSet, true);
|
||||
for (const auto emoji : exact) {
|
||||
_searchEmoticon += emoji->text();
|
||||
}
|
||||
}
|
||||
_searchResults.clear();
|
||||
_searchCustomIds.clear();
|
||||
|
||||
@@ -146,7 +146,8 @@ rpl::producer<std::vector<GifSection>> GifSectionsValue(
|
||||
|
||||
[[nodiscard]] std::vector<EmojiPtr> SearchEmoji(
|
||||
const std::vector<QString> &query,
|
||||
base::flat_set<EmojiPtr> &outResultSet) {
|
||||
base::flat_set<EmojiPtr> &outResultSet,
|
||||
bool exact) {
|
||||
auto result = std::vector<EmojiPtr>();
|
||||
const auto pushPlain = [&](EmojiPtr emoji) {
|
||||
if (result.size() < kEmojiSearchLimit
|
||||
@@ -170,7 +171,7 @@ rpl::producer<std::vector<GifSection>> GifSectionsValue(
|
||||
refreshed = true;
|
||||
keywords.refresh();
|
||||
}
|
||||
const auto list = keywords.queryMine(entry);
|
||||
const auto list = keywords.queryMine(entry, exact);
|
||||
for (const auto &entry : list) {
|
||||
pushPlain(entry.emoji);
|
||||
if (result.size() >= kEmojiSearchLimit) {
|
||||
|
||||
@@ -70,7 +70,8 @@ struct GifSection {
|
||||
|
||||
[[nodiscard]] std::vector<EmojiPtr> SearchEmoji(
|
||||
const std::vector<QString> &query,
|
||||
base::flat_set<EmojiPtr> &outResultSet);
|
||||
base::flat_set<EmojiPtr> &outResultSet,
|
||||
bool exact = false);
|
||||
|
||||
struct StickerIcon {
|
||||
explicit StickerIcon(uint64 setId);
|
||||
|
||||
@@ -80,7 +80,7 @@ private:
|
||||
};
|
||||
|
||||
[[nodiscard]] std::vector<QString> FieldQuery(not_null<InputField*> field) {
|
||||
if (const auto last = field->getLastText(); !last.isEmpty()) {
|
||||
if (const auto last = field->getLastText().trimmed(); !last.isEmpty()) {
|
||||
return { last };
|
||||
}
|
||||
return {};
|
||||
|
||||
Reference in New Issue
Block a user