Skip to content

armgit / ente

Public Imported from GitHub
0

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

Show the option for beta users too

Manav Rathifa06a15ad727
diff --git a/web/apps/photos/src/components/ml/MLSearchSettings.tsx b/web/apps/photos/src/components/ml/MLSearchSettings.tsx
index d71dffab7e..1f3ad752a3 100644
--- a/web/apps/photos/src/components/ml/MLSearchSettings.tsx
+++ b/web/apps/photos/src/components/ml/MLSearchSettings.tsx
@@ -18,11 +18,11 @@ import { t } from "i18next";
import { AppContext } from "pages/_app";
import { useContext, useEffect, useState } from "react";
import { Trans } from "react-i18next";
+import { canEnableFaceIndexing } from "services/face/indexer";
import {
getFaceSearchEnabledStatus,
updateFaceSearchEnabledStatus,
} from "services/userService";
-import { isInternalUserForML } from "utils/user";
export const MLSearchSettings = ({ open, onClose, onRootClose }) => {
const {
@@ -258,6 +258,12 @@ function EnableMLSearch({ onClose, enableMlSearch, onRootClose }) {
// const showDetails = () =>
// openLink("https://ente.io/blog/desktop-ml-beta", true);
+ const [canEnable, setCanEnable] = useState(false);
+
+ useEffect(() => {
+ canEnableFaceIndexing().then((v) => setCanEnable(v));
+ }, []);
+
return (
<Stack spacing={"4px"} py={"12px"}>
<Titlebar
@@ -273,7 +279,7 @@ function EnableMLSearch({ onClose, enableMlSearch, onRootClose }) {
We're putting finishing touches, coming back soon!
</Typography>
</Box>
- {isInternalUserForML() && (
+ {canEnable && (
<Stack px={"8px"} spacing={"8px"}>
<Button
color={"accent"}
diff --git a/web/apps/photos/src/services/face/indexer.ts b/web/apps/photos/src/services/face/indexer.ts
index 095e65d400..7b446b42e1 100644
--- a/web/apps/photos/src/services/face/indexer.ts
+++ b/web/apps/photos/src/services/face/indexer.ts
@@ -2,6 +2,7 @@ import { ComlinkWorker } from "@/next/worker/comlink-worker";
import { ensure } from "@/utils/ensure";
import { wait } from "@/utils/promise";
import { type Remote } from "comlink";
+import { isBetaUser, isInternalUser } from "services/feature-flag";
import { getAllLocalFiles } from "services/fileService";
import mlWorkManager from "services/machineLearning/mlWorkManager";
import type { EnteFile } from "types/file";
@@ -194,6 +195,13 @@ export const unidentifiedFaceIDs = async (
return index?.faceEmbedding.faces.map((f) => f.faceID) ?? [];
};
+/**
+ * Return true if we should show an option to the user to allow them to enable
+ * face search in the UI.
+ */
+export const canEnableFaceIndexing = async () =>
+ isInternalUserForML() || (await isInternalUser()) || (await isBetaUser());
+
/**
* Return true if the user has enabled face indexing in the app's settings.
*
@@ -204,12 +212,7 @@ export const unidentifiedFaceIDs = async (
* hand, denotes whether or not indexing is enabled on the current client.
*/
export const isFaceIndexingEnabled = async () => {
- if (isInternalUserForML()) {
- return localStorage.getItem("faceIndexingEnabled") == "1";
- }
- // Force disabled for everyone else while we finalize it to avoid redundant
- // reindexing for users.
- return false;
+ return localStorage.getItem("faceIndexingEnabled") == "1";
};
/**
diff --git a/web/apps/photos/src/services/feature-flag.ts b/web/apps/photos/src/services/feature-flag.ts
index 0c15ec3cbb..7fb4368a6d 100644
--- a/web/apps/photos/src/services/feature-flag.ts
+++ b/web/apps/photos/src/services/feature-flag.ts
@@ -80,7 +80,19 @@ const remoteFeatureFlagsFetchingIfNeeded = async () => {
/**
* Return `true` if the current user is marked as an "internal" user.
*/
-export const isInternalUser = async () => {};
+export const isInternalUser = async () => {
+ // TODO: Dedup
+ const flags = await remoteFeatureFlagsFetchingIfNeeded();
+ // TODO(MR): Use Yup here
+ if (
+ flags &&
+ typeof flags === "object" &&
+ "internalUser" in flags &&
+ typeof flags.internalUser == "boolean"
+ )
+ return flags.internalUser;
+ return false;
+};
/**
* Return `true` if the current user is marked as a "beta" user.