mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-25 07:23:43 +01:00
When searching for an emoji with multiple separators, consider the full input (#9124)
e.g., typing “blob_cat_p” used to search for “blob” and “cat”, but not “blob_cat_p”, which means “blob_cat_patpat” is very unlikely to show up, although it is likely what the user wanted to type in the first place.
This commit is contained in:
parent
eef8d9a5f7
commit
a90b569350
1 changed files with 15 additions and 7 deletions
|
@ -2,7 +2,7 @@
|
||||||
// https://github.com/missive/emoji-mart/blob/5f2ffcc/src/utils/emoji-index.js
|
// https://github.com/missive/emoji-mart/blob/5f2ffcc/src/utils/emoji-index.js
|
||||||
|
|
||||||
import data from './emoji_mart_data_light';
|
import data from './emoji_mart_data_light';
|
||||||
import { getData, getSanitizedData, intersect } from './emoji_utils';
|
import { getData, getSanitizedData, uniq, intersect } from './emoji_utils';
|
||||||
|
|
||||||
let originalPool = {};
|
let originalPool = {};
|
||||||
let index = {};
|
let index = {};
|
||||||
|
@ -103,7 +103,7 @@ function search(value, { emojisToShowFilter, maxResults, include, exclude, custo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
allResults = values.map((value) => {
|
const searchValue = (value) => {
|
||||||
let aPool = pool,
|
let aPool = pool,
|
||||||
aIndex = index,
|
aIndex = index,
|
||||||
length = 0;
|
length = 0;
|
||||||
|
@ -150,15 +150,23 @@ function search(value, { emojisToShowFilter, maxResults, include, exclude, custo
|
||||||
}
|
}
|
||||||
|
|
||||||
return aIndex.results;
|
return aIndex.results;
|
||||||
}).filter(a => a);
|
};
|
||||||
|
|
||||||
if (allResults.length > 1) {
|
if (values.length > 1) {
|
||||||
results = intersect.apply(null, allResults);
|
results = searchValue(value);
|
||||||
} else if (allResults.length) {
|
|
||||||
results = allResults[0];
|
|
||||||
} else {
|
} else {
|
||||||
results = [];
|
results = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allResults = values.map(searchValue).filter(a => a);
|
||||||
|
|
||||||
|
if (allResults.length > 1) {
|
||||||
|
allResults = intersect.apply(null, allResults);
|
||||||
|
} else if (allResults.length) {
|
||||||
|
allResults = allResults[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
results = uniq(results.concat(allResults));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (results) {
|
if (results) {
|
||||||
|
|
Loading…
Reference in a new issue