Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Use in search bar

Manav Rathia3dc69188554
diff --git a/web/apps/photos/src/services/searchService.ts b/web/apps/photos/src/services/searchService.ts
index 42b35c57a9..fc89877759 100644
--- a/web/apps/photos/src/services/searchService.ts
+++ b/web/apps/photos/src/services/searchService.ts
@@ -1,5 +1,5 @@
import { FILE_TYPE } from "@/media/file-type";
-import { mlStatusSnapshot } from "@/new/photos/services/ml";
+import { isMLSupported, mlStatusSnapshot } from "@/new/photos/services/ml";
import type { Person } from "@/new/photos/services/ml/people";
import { EnteFile } from "@/new/photos/types/file";
import { isDesktop } from "@/next/app";
@@ -26,7 +26,7 @@ const DIGITS = new Set(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]);
export const getDefaultOptions = async () => {
return [
- ...(await getMLStatusSuggestion()),
+ await getMLStatusSuggestion(),
...(await convertSuggestionsToOptions(await getAllPeopleSuggestion())),
].filter((t) => !!t);
};
@@ -169,38 +169,38 @@ export async function getAllPeopleSuggestion(): Promise<Array<Suggestion>> {
}
}
-export async function getMLStatusSuggestion(): Promise<Suggestion[]> {
- const status = await mlStatusSnapshot();
+export async function getMLStatusSuggestion(): Promise<Suggestion> {
+ if (!isMLSupported) return undefined;
- isMLEnabled();
- try {
- let label: string;
- switch (status.phase) {
- case "scheduled":
- label = t("INDEXING_SCHEDULED");
- break;
- case "indexing":
- label = t("ANALYZING_PHOTOS", {
- indexStatus: status,
- });
- break;
- case "clustering":
- label = t("INDEXING_PEOPLE", { indexStatus: status });
- break;
- case "done":
- label = t("INDEXING_DONE", { indexStatus: status });
- break;
- }
+ const status = mlStatusSnapshot();
- return {
- label,
- type: SuggestionType.INDEX_STATUS,
- value: status,
- hide: true,
- };
- } catch (e) {
- log.error("getIndexStatusSuggestion failed", e);
+ if (!status || status.phase == "disabled" || status.phase == "paused")
+ return undefined;
+
+ let label: string;
+ switch (status.phase) {
+ case "scheduled":
+ label = t("INDEXING_SCHEDULED");
+ break;
+ case "indexing":
+ label = t("ANALYZING_PHOTOS", {
+ indexStatus: status,
+ });
+ break;
+ case "clustering":
+ label = t("INDEXING_PEOPLE", { indexStatus: status });
+ break;
+ case "done":
+ label = t("INDEXING_DONE", { indexStatus: status });
+ break;
}
+
+ return {
+ label,
+ type: SuggestionType.INDEX_STATUS,
+ value: status,
+ hide: true,
+ };
}
function getDateSuggestion(searchPhrase: string): Suggestion[] {
diff --git a/web/packages/new/photos/services/ml/index.ts b/web/packages/new/photos/services/ml/index.ts
index 8ac088253d..3152980886 100644
--- a/web/packages/new/photos/services/ml/index.ts
+++ b/web/packages/new/photos/services/ml/index.ts
@@ -334,8 +334,8 @@ export const mlStatusSubscribe = (onChange: () => void): (() => void) => {
*/
export const mlStatusSnapshot = (): MLStatus | undefined => {
const result = _mlStatusSnapshot;
- // We don't have it yet but we're on a supported client, trigger an update.
- if (!result && isDesktop) triggerStatusUpdate();
+ // We don't have it yet, trigger an update.
+ if (!result) triggerStatusUpdate();
return result;
};