diff --git a/web/apps/photos/src/components/Sidebar/Preferences.tsx b/web/apps/photos/src/components/Sidebar/Preferences.tsx
index 5975059af9..32c36f991c 100644
--- a/web/apps/photos/src/components/Sidebar/Preferences.tsx
+++ b/web/apps/photos/src/components/Sidebar/Preferences.tsx
@@ -1,4 +1,5 @@
import { MLSettings } from "@/new/photos/components/MLSettings";
+import { isMLSupported } from "@/new/photos/services/ml";
import { EnteDrawer } from "@/new/shared/components/EnteDrawer";
import { MenuItemGroup, MenuSectionTitle } from "@/new/shared/components/Menu";
import { Titlebar } from "@/new/shared/components/Titlebar";
@@ -15,7 +16,6 @@ import ScienceIcon from "@mui/icons-material/Science";
import { Box, DialogProps, Stack } from "@mui/material";
import DropdownInput from "components/DropdownInput";
import { t } from "i18next";
-import isElectron from "is-electron";
import { AppContext } from "pages/_app";
import { useContext, useState } from "react";
import AdvancedSettings from "./AdvancedSettings";
@@ -75,7 +75,7 @@ export default function Preferences({ open, onClose, onRootClose }) {
endIcon={}
label={t("ADVANCED")}
/>
- {isElectron() && (
+ {isMLSupported && (
{
return [
- // TODO-ML(MR): Skip this for now if indexing is disabled (eventually
- // the indexing status should not be tied to results).
- ...(isMLEnabled() ? [await getIndexStatusSuggestion()] : []),
+ ...(await getMLStatusSuggestion()),
...(await convertSuggestionsToOptions(await getAllPeopleSuggestion())),
].filter((t) => !!t);
};
@@ -171,32 +169,33 @@ export async function getAllPeopleSuggestion(): Promise> {
}
}
-export async function getIndexStatusSuggestion(): Promise {
- try {
- const indexStatus = await faceIndexingStatus();
+export async function getMLStatusSuggestion(): Promise {
+ const status = await mlStatusSnapshot();
+ isMLEnabled();
+ try {
let label: string;
- switch (indexStatus.phase) {
+ switch (status.phase) {
case "scheduled":
label = t("INDEXING_SCHEDULED");
break;
case "indexing":
label = t("ANALYZING_PHOTOS", {
- indexStatus,
+ indexStatus: status,
});
break;
case "clustering":
- label = t("INDEXING_PEOPLE", { indexStatus });
+ label = t("INDEXING_PEOPLE", { indexStatus: status });
break;
case "done":
- label = t("INDEXING_DONE", { indexStatus });
+ label = t("INDEXING_DONE", { indexStatus: status });
break;
}
return {
label,
type: SuggestionType.INDEX_STATUS,
- value: indexStatus,
+ value: status,
hide: true,
};
} catch (e) {
diff --git a/web/apps/photos/src/services/sync.ts b/web/apps/photos/src/services/sync.ts
index b628a3510d..5ebc5b43b0 100644
--- a/web/apps/photos/src/services/sync.ts
+++ b/web/apps/photos/src/services/sync.ts
@@ -1,6 +1,5 @@
import { fetchAndSaveFeatureFlagsIfNeeded } from "@/new/photos/services/feature-flags";
-import { triggerMLSync } from "@/new/photos/services/ml";
-import { isDesktop } from "@/next/app";
+import { isMLSupported, triggerMLSync } from "@/new/photos/services/ml";
import { syncEntities } from "services/entityService";
import { syncMapEnabled } from "services/userService";
@@ -17,7 +16,5 @@ export const sync = async () => {
await syncEntities();
await syncMapEnabled();
fetchAndSaveFeatureFlagsIfNeeded();
- if (isDesktop) {
- triggerMLSync();
- }
+ if (isMLSupported) triggerMLSync();
};
diff --git a/web/packages/new/photos/services/ml/index.ts b/web/packages/new/photos/services/ml/index.ts
index f5a501151d..8ac088253d 100644
--- a/web/packages/new/photos/services/ml/index.ts
+++ b/web/packages/new/photos/services/ml/index.ts
@@ -93,17 +93,17 @@ export const terminateMLWorker = () => {
}
};
-/** Gatekeep some common entry points to catch accidental invocations. */
-const ensureDesktop = () => {
- // ML currently only works when we're running in our desktop app.
- if (!isDesktop) throw new Error("ML subsystem can only be used on desktop");
-};
+/**
+ * Return true if the current client supports ML.
+ *
+ * ML currently only works when we're running in our desktop app.
+ */
+export const isMLSupported = isDesktop;
/**
* Initialize the ML subsystem if the user has enabled it in preferences.
*/
export const initML = () => {
- ensureDesktop();
_isMLEnabledLocal = isMLEnabledLocally();
};
@@ -247,10 +247,7 @@ const updateIsMLEnabledRemote = (enabled: boolean) =>
* This function does not wait for these processes to run to completion, and
* returns immediately.
*/
-export const triggerMLSync = () => {
- ensureDesktop();
- void mlSync();
-};
+export const triggerMLSync = () => void mlSync();
const mlSync = async () => {
_isMLEnabledRemote = await getIsMLEnabledRemote();
@@ -337,8 +334,8 @@ export const mlStatusSubscribe = (onChange: () => void): (() => void) => {
*/
export const mlStatusSnapshot = (): MLStatus | undefined => {
const result = _mlStatusSnapshot;
- // We don't have it yet, so start figuring it out now.
- if (!result) triggerStatusUpdate();
+ // We don't have it yet but we're on a supported client, trigger an update.
+ if (!result && isDesktop) triggerStatusUpdate();
return result;
};