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 ( return (
<Menu {...props}> <Menu {...props}>
{appContext.mlSearchEnabled && ( <Col>
<Col> {appContext.mlSearchEnabled && indexStatus && (
<LegendRow> <LegendRow>
<Legend>{constants.PEOPLE}</Legend> <>
{indexStatus && ( <Legend>{constants.PEOPLE}</Legend>
<Caption>{indexStatusSuggestion.label}</Caption> <Caption>{indexStatusSuggestion.label}</Caption>
)} </>
</LegendRow> </LegendRow>
{people && people.length > 0 && ( )}
{people && people.length > 0 && (
<>
<LegendRow>
<Legend>{constants.PEOPLE}</Legend>
</LegendRow>
<Row> <Row>
<PeopleList <PeopleList
people={people} people={people}
maxRows={2} maxRows={2}
onSelect={(person, index) => { onSelect={(_, index) => {
props.selectRef.current.blur(); props.selectRef.current.blur();
props.setValue(peopleSuggestions[index]); props.setValue(peopleSuggestions[index]);
}}></PeopleList> }}
/>
</Row> </Row>
)} </>
</Col> )}
)} </Col>
{props.children} {props.children}
</Menu> </Menu>
); );

View file

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

View file

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