show ml result even if indexing is turned off

This commit is contained in:
Abhinav 2022-08-02 11:57:35 +05:30
parent 7acedc32a4
commit 47f317daf4
3 changed files with 37 additions and 28 deletions

View file

@ -40,27 +40,33 @@ const MenuWithPeople = (props) => {
return (
<Menu {...props}>
{appContext.mlSearchEnabled && (
<Col>
<Col>
{appContext.mlSearchEnabled && indexStatus && (
<LegendRow>
<Legend>{constants.PEOPLE}</Legend>
{indexStatus && (
<>
<Legend>{constants.PEOPLE}</Legend>
<Caption>{indexStatusSuggestion.label}</Caption>
)}
</>
</LegendRow>
{people && people.length > 0 && (
)}
{people && people.length > 0 && (
<>
<LegendRow>
<Legend>{constants.PEOPLE}</Legend>
</LegendRow>
<Row>
<PeopleList
people={people}
maxRows={2}
onSelect={(person, index) => {
onSelect={(_, index) => {
props.selectRef.current.blur();
props.setValue(peopleSuggestions[index]);
}}></PeopleList>
}}
/>
</Row>
)}
</Col>
)}
</>
)}
</Col>
{props.children}
</Menu>
);

View file

@ -97,12 +97,10 @@ export default function SearchInput(props: Iprops) {
// https://github.com/JedWatson/react-select/issues/1879
// for correct fix AsyncSelect can be extended to support default options reloading on focus/click
const handleOnFocus = () => {
if (appContext.mlSearchEnabled) {
const emptySearch = ' ';
selectRef.current.state.inputValue = emptySearch;
selectRef.current.select.state.inputValue = emptySearch;
selectRef.current.handleInputChange(emptySearch);
}
const emptySearch = ' ';
selectRef.current.state.inputValue = emptySearch;
selectRef.current.select.state.inputValue = emptySearch;
selectRef.current.handleInputChange(emptySearch);
};
return (

View file

@ -32,17 +32,22 @@ export const getAutoCompleteSuggestions =
(files: EnteFile[], collections: Collection[]) =>
async (searchPhrase: string) => {
searchPhrase = searchPhrase.trim().toLowerCase();
const suggestions = [];
suggestions.push(await getIndexStatusSuggestion());
suggestions.push(...(await getAllPeopleSuggestion()));
if (!searchPhrase?.length) {
return [];
return suggestions;
}
const suggestions = [
...getHolidaySuggestion(searchPhrase),
...getYearSuggestion(searchPhrase),
...getDateSuggestion(searchPhrase),
...getCollectionSuggestion(searchPhrase, collections),
...getFileSuggestion(searchPhrase, files),
...(await getLocationSuggestions(searchPhrase)),
];
suggestions.push(
...[
...getHolidaySuggestion(searchPhrase),
...getYearSuggestion(searchPhrase),
...getDateSuggestion(searchPhrase),
...getCollectionSuggestion(searchPhrase, collections),
...getFileSuggestion(searchPhrase, files),
...(await getLocationSuggestions(searchPhrase)),
]
);
const previewImageAppendedOptions: SearchOption[] = suggestions
.map((suggestion) => ({
@ -58,8 +63,8 @@ export const getAutoCompleteSuggestions =
fileCount: resultFiles.length,
previewFiles: resultFiles.slice(0, 3),
};
})
.filter((option) => option.fileCount);
});
// .filter((option) => option.fileCount);
return previewImageAppendedOptions;
};