show ml result even if indexing is turned off
This commit is contained in:
parent
7acedc32a4
commit
47f317daf4
|
@ -40,27 +40,33 @@ const MenuWithPeople = (props) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Menu {...props}>
|
<Menu {...props}>
|
||||||
{appContext.mlSearchEnabled && (
|
|
||||||
<Col>
|
<Col>
|
||||||
|
{appContext.mlSearchEnabled && indexStatus && (
|
||||||
|
<LegendRow>
|
||||||
|
<>
|
||||||
|
<Legend>{constants.PEOPLE}</Legend>
|
||||||
|
<Caption>{indexStatusSuggestion.label}</Caption>
|
||||||
|
</>
|
||||||
|
</LegendRow>
|
||||||
|
)}
|
||||||
|
{people && people.length > 0 && (
|
||||||
|
<>
|
||||||
<LegendRow>
|
<LegendRow>
|
||||||
<Legend>{constants.PEOPLE}</Legend>
|
<Legend>{constants.PEOPLE}</Legend>
|
||||||
{indexStatus && (
|
|
||||||
<Caption>{indexStatusSuggestion.label}</Caption>
|
|
||||||
)}
|
|
||||||
</LegendRow>
|
</LegendRow>
|
||||||
{people && people.length > 0 && (
|
|
||||||
<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>
|
||||||
);
|
);
|
||||||
|
|
|
@ -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 (
|
||||||
|
|
|
@ -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),
|
...getHolidaySuggestion(searchPhrase),
|
||||||
...getYearSuggestion(searchPhrase),
|
...getYearSuggestion(searchPhrase),
|
||||||
...getDateSuggestion(searchPhrase),
|
...getDateSuggestion(searchPhrase),
|
||||||
...getCollectionSuggestion(searchPhrase, collections),
|
...getCollectionSuggestion(searchPhrase, collections),
|
||||||
...getFileSuggestion(searchPhrase, files),
|
...getFileSuggestion(searchPhrase, files),
|
||||||
...(await getLocationSuggestions(searchPhrase)),
|
...(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;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue