Merge branch 'main' into onnx-clip-ui
This commit is contained in:
commit
6837225281
4 changed files with 37 additions and 25 deletions
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
@ -11,7 +11,7 @@
|
|||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnPaste": true,
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll": true
|
||||
"source.fixAll": "explicit"
|
||||
},
|
||||
"typescript.enablePromptUseWorkspaceTsdk": true
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ export const getDefaultOptions = async (files: EnteFile[]) => {
|
|||
return [
|
||||
await getIndexStatusSuggestion(),
|
||||
...convertSuggestionsToOptions(await getAllPeopleSuggestion(), files),
|
||||
];
|
||||
].filter((t) => !!t);
|
||||
};
|
||||
|
||||
export const getAutoCompleteSuggestions =
|
||||
|
@ -174,7 +174,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,
|
||||
|
@ -188,28 +190,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[] {
|
||||
|
|
|
@ -2237,9 +2237,9 @@ fn-name@~3.0.0:
|
|||
integrity sha512-eNMNr5exLoavuAMhIUVsOKF79SWd/zG104ef6sxBTSw+cZc6BXdQXDvYcGvp0VbxVVSp1XDUNoz7mg1xMtSznA==
|
||||
|
||||
follow-redirects@^1.15.0:
|
||||
version "1.15.2"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
|
||||
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==
|
||||
version "1.15.4"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.4.tgz#cdc7d308bf6493126b17ea2191ea0ccf3e535adf"
|
||||
integrity sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==
|
||||
|
||||
for-each@^0.3.3:
|
||||
version "0.3.3"
|
||||
|
|
Loading…
Add table
Reference in a new issue