wip separate flag
This commit is contained in:
@@ -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={<ChevronRight />}
|
||||
label={t("ADVANCED")}
|
||||
/>
|
||||
{isElectron() && (
|
||||
{isMLSupported && (
|
||||
<Box>
|
||||
<MenuSectionTitle
|
||||
title={t("LABS")}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { AccountsContextT } from "@/accounts/types/context";
|
||||
import DownloadManager from "@/new/photos/services/download";
|
||||
import { initML } from "@/new/photos/services/ml";
|
||||
import { initML, isMLSupported } from "@/new/photos/services/ml";
|
||||
import { clientPackageName, staticAppTitle } from "@/next/app";
|
||||
import { CustomHead } from "@/next/components/Head";
|
||||
import { setupI18n } from "@/next/i18n";
|
||||
@@ -174,7 +174,7 @@ export default function App({ Component, pageProps }: AppProps) {
|
||||
}
|
||||
};
|
||||
|
||||
initML();
|
||||
if (isMLSupported) initML();
|
||||
|
||||
electron.onOpenURL(handleOpenURL);
|
||||
electron.onAppUpdateAvailable(showUpdateDialog);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { FILE_TYPE } from "@/media/file-type";
|
||||
import { faceIndexingStatus, isMLEnabled } from "@/new/photos/services/ml";
|
||||
import { 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,9 +26,7 @@ const DIGITS = new Set(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]);
|
||||
|
||||
export const getDefaultOptions = async () => {
|
||||
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<Array<Suggestion>> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getIndexStatusSuggestion(): Promise<Suggestion> {
|
||||
try {
|
||||
const indexStatus = await faceIndexingStatus();
|
||||
export async function getMLStatusSuggestion(): Promise<Suggestion[]> {
|
||||
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) {
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user