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

View File

@ -8,6 +8,7 @@
// //
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
import { isDevBuild } from "@/base/env";
import { localUser } from "@/base/local-user"; import { localUser } from "@/base/local-user";
import log from "@/base/log"; import log from "@/base/log";
import { updateShouldDisableCFUploadProxy } from "@/gallery/services/upload"; import { updateShouldDisableCFUploadProxy } from "@/gallery/services/upload";
@ -152,7 +153,7 @@ type FeatureFlags = z.infer<typeof FeatureFlags>;
const syncSettingsSnapshotWithLocalStorage = () => { const syncSettingsSnapshotWithLocalStorage = () => {
const flags = savedRemoteFeatureFlags(); const flags = savedRemoteFeatureFlags();
const settings = createDefaultSettings(); const settings = createDefaultSettings();
settings.isInternalUser = flags?.internalUser || isInternalUserViaEmail(); settings.isInternalUser = flags?.internalUser || false;
settings.mapEnabled = flags?.mapEnabled || false; settings.mapEnabled = flags?.mapEnabled || false;
settings.cfUploadProxyDisabled = savedCFProxyDisabled(); settings.cfUploadProxyDisabled = savedCFProxyDisabled();
if (flags?.castUrl) settings.castURL = flags.castUrl; if (flags?.castUrl) settings.castURL = flags.castUrl;
@ -185,20 +186,19 @@ const setSettingsSnapshot = (snapshot: Settings) => {
_state.settingsListeners.forEach((l) => l()); _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(); const user = localUser();
return !!user?.email.endsWith("@ente.io"); 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. * Persist the user's map enabled preference both locally and on remote.
*/ */