[web] Match mobile's internal user spec (#5217)

This commit is contained in:
Manav Rathi 2025-03-03 14:33:43 +05:30 committed by GitHub
commit 631257de3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 14 deletions

View File

@ -25,7 +25,6 @@ import {
type ModalVisibilityProps,
} from "@/base/components/utils/modal";
import { useBaseContext } from "@/base/context";
import { isDevBuild } from "@/base/env";
import {
getLocaleInUse,
setLocaleInUse,
@ -58,7 +57,7 @@ import {
import type { CollectionSummaries } from "@/new/photos/services/collection/ui";
import { isMLSupported } from "@/new/photos/services/ml";
import {
isInternalUser,
isDevBuildAndUser,
syncSettings,
updateCFProxyDisabledPreference,
updateMapEnabled,
@ -1148,7 +1147,7 @@ const Help: React.FC<NestedSidebarDrawerVisibilityProps> = ({
}
onClick={confirmViewLogs}
/>
{isInternalUser() && isDevBuild && (
{isDevBuildAndUser() && (
<RowButton
variant="secondary"
label={

View File

@ -8,6 +8,7 @@
//
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
import { isDevBuild } from "@/base/env";
import { localUser } from "@/base/local-user";
import log from "@/base/log";
import { updateShouldDisableCFUploadProxy } from "@/gallery/services/upload";
@ -152,7 +153,7 @@ type FeatureFlags = z.infer<typeof FeatureFlags>;
const syncSettingsSnapshotWithLocalStorage = () => {
const flags = savedRemoteFeatureFlags();
const settings = createDefaultSettings();
settings.isInternalUser = flags?.internalUser || isInternalUserViaEmail();
settings.isInternalUser = flags?.internalUser || false;
settings.mapEnabled = flags?.mapEnabled || false;
settings.cfUploadProxyDisabled = savedCFProxyDisabled();
if (flags?.castUrl) settings.castURL = flags.castUrl;
@ -185,20 +186,19 @@ const setSettingsSnapshot = (snapshot: Settings) => {
_state.settingsListeners.forEach((l) => l());
};
const isInternalUserViaEmail = () => {
/**
* Return `true` if this is a development build, and the current user is marked
* as an "development" user.
*
* Emails that end in "@ente.io" are considered as dev users.
*/
export const isDevBuildAndUser = () => isDevBuild && isDevUserViaEmail();
const isDevUserViaEmail = () => {
const user = localUser();
return !!user?.email.endsWith("@ente.io");
};
/**
* Return `true` if the current user is marked as an "internal" user.
*
* 1. Emails that end in `@ente.io` are considered as internal users.
* 2. If the "internalUser" remote feature flag is set, the user is internal.
* 3. Otherwise false.
*/
export const isInternalUser = () => settingsSnapshot().isInternalUser;
/**
* Persist the user's map enabled preference both locally and on remote.
*/