Fix face indexing status update issue (#1542)
This commit is contained in:
commit
322c70aaa8
|
@ -34,6 +34,7 @@ import { t } from 'i18next';
|
|||
import memoize from 'memoize-one';
|
||||
import { LocationTagData } from 'types/entity';
|
||||
import { FILE_TYPE } from 'constants/file';
|
||||
import { addLogLine } from '@ente/shared/logging';
|
||||
|
||||
interface Iprops {
|
||||
isOpen: boolean;
|
||||
|
@ -64,10 +65,15 @@ export default function SearchInput(props: Iprops) {
|
|||
|
||||
useEffect(() => {
|
||||
refreshDefaultOptions();
|
||||
const t = setInterval(() => refreshDefaultOptions(), 2000);
|
||||
return () => clearInterval(t);
|
||||
}, []);
|
||||
|
||||
async function refreshDefaultOptions() {
|
||||
const t = Date.now();
|
||||
addLogLine('refreshDefaultOptions called');
|
||||
const defaultOptions = await getDefaultOptions(props.files);
|
||||
addLogLine(`refreshDefaultOptions end time: ${Date.now() - t}ms`);
|
||||
setDefaultOptions(defaultOptions);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ export const getDefaultOptions = async (files: EnteFile[]) => {
|
|||
return [
|
||||
await getIndexStatusSuggestion(),
|
||||
...convertSuggestionsToOptions(await getAllPeopleSuggestion(), files),
|
||||
];
|
||||
].filter((t) => !!t);
|
||||
};
|
||||
|
||||
export const getAutoCompleteSuggestions =
|
||||
|
@ -176,7 +176,9 @@ function getYearSuggestion(searchPhrase: string): Suggestion[] {
|
|||
|
||||
export async function getAllPeopleSuggestion(): Promise<Array<Suggestion>> {
|
||||
try {
|
||||
addLogLine('getAllPeopleSuggestion called');
|
||||
const people = await getAllPeople(200);
|
||||
addLogLine(`found people: ${people?.length ?? 0}`);
|
||||
return people.map((person) => ({
|
||||
label: person.name,
|
||||
type: SuggestionType.PERSON,
|
||||
|
@ -190,28 +192,32 @@ export async function getAllPeopleSuggestion(): Promise<Array<Suggestion>> {
|
|||
}
|
||||
|
||||
export async function getIndexStatusSuggestion(): Promise<Suggestion> {
|
||||
const config = await getMLSyncConfig();
|
||||
const indexStatus = await mlIDbStorage.getIndexStatus(config.mlVersion);
|
||||
try {
|
||||
const config = await getMLSyncConfig();
|
||||
const indexStatus = await mlIDbStorage.getIndexStatus(config.mlVersion);
|
||||
|
||||
let label;
|
||||
if (!indexStatus.localFilesSynced) {
|
||||
label = t('INDEXING_SCHEDULED');
|
||||
} else if (indexStatus.outOfSyncFilesExists) {
|
||||
label = t('ANALYZING_PHOTOS', {
|
||||
indexStatus,
|
||||
});
|
||||
} else if (!indexStatus.peopleIndexSynced) {
|
||||
label = t('INDEXING_PEOPLE', { indexStatus });
|
||||
} else {
|
||||
label = t('INDEXING_DONE', { indexStatus });
|
||||
let label;
|
||||
if (!indexStatus.localFilesSynced) {
|
||||
label = t('INDEXING_SCHEDULED');
|
||||
} else if (indexStatus.outOfSyncFilesExists) {
|
||||
label = t('ANALYZING_PHOTOS', {
|
||||
indexStatus,
|
||||
});
|
||||
} else if (!indexStatus.peopleIndexSynced) {
|
||||
label = t('INDEXING_PEOPLE', { indexStatus });
|
||||
} else {
|
||||
label = t('INDEXING_DONE', { indexStatus });
|
||||
}
|
||||
|
||||
return {
|
||||
label,
|
||||
type: SuggestionType.INDEX_STATUS,
|
||||
value: indexStatus,
|
||||
hide: true,
|
||||
};
|
||||
} catch (e) {
|
||||
logError(e, 'getIndexStatusSuggestion failed');
|
||||
}
|
||||
|
||||
return {
|
||||
label,
|
||||
type: SuggestionType.INDEX_STATUS,
|
||||
value: indexStatus,
|
||||
hide: true,
|
||||
};
|
||||
}
|
||||
|
||||
function getDateSuggestion(searchPhrase: string): Suggestion[] {
|
||||
|
|
Loading…
Reference in a new issue