π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Start using
Manav Rathi98ad12b4154d
diff --git a/web/apps/photos/src/components/Sidebar/Preferences.tsx b/web/apps/photos/src/components/Sidebar/Preferences.tsxindex f133e96a4b..975012bd01 100644--- a/web/apps/photos/src/components/Sidebar/Preferences.tsx+++ b/web/apps/photos/src/components/Sidebar/Preferences.tsx@@ -13,13 +13,14 @@ import {} from "@/base/i18n";import { MLSettings } from "@/new/photos/components/MLSettings";import { isMLSupported } from "@/new/photos/services/ml";+import { syncSettings } from "@/new/photos/services/settings";import { EnteMenuItem } from "@ente/shared/components/Menu/EnteMenuItem";import ChevronRight from "@mui/icons-material/ChevronRight";import ScienceIcon from "@mui/icons-material/Science";import { Box, DialogProps, Stack } from "@mui/material";import DropdownInput from "components/DropdownInput";import { t } from "i18next";-import React from "react";+import React, { useEffect } from "react";import { AdvancedSettings } from "./AdvancedSettings";import { MapSettings } from "./MapSetting";@@ -37,6 +38,10 @@ export const Preferences: React.FC<NestedDrawerVisibilityProps> = ({const { show: showMLSettings, props: mlSettingsVisibilityProps } =useModalVisibility();+ useEffect(() => {+ if (open) void syncSettings();+ }, [open]);+const handleRootClose = () => {onClose();onRootClose();diff --git a/web/apps/photos/src/components/Sidebar/index.tsx b/web/apps/photos/src/components/Sidebar/index.tsxindex a053a42f14..1d090d52b4 100644--- a/web/apps/photos/src/components/Sidebar/index.tsx+++ b/web/apps/photos/src/components/Sidebar/index.tsx@@ -16,6 +16,7 @@ import {TRASH_SECTION,} from "@/new/photos/services/collection";import type { CollectionSummaries } from "@/new/photos/services/collection/ui";+import { isInternalUser } from "@/new/photos/services/settings";import { AppContext, useAppContext } from "@/new/photos/types/context";import { initiateEmail, openURL } from "@/new/photos/utils/web";import { SpaceBetweenFlex } from "@ente/shared/components/Container";@@ -482,7 +483,7 @@ const UtilitySection: React.FC<UtilitySectionProps> = ({ closeSidebar }) => {onClick={showRecoveryKey}label={t("recovery_key")}/>- {isInternalUserViaEmailCheck() && (+ {isInternalUser() && (<EnteMenuItemonClick={toggleTheme}variant="secondary"@@ -653,7 +654,7 @@ const DebugSection: React.FC = () => {return (<>- {isInternalUserViaEmailCheck() && (+ {isInternalUser() && (<EnteMenuItemvariant="secondary"onClick={testUpload}@@ -674,11 +675,3 @@ const DebugSection: React.FC = () => {</>);};--// TODO: Legacy synchronous check, use the one from remote-store.ts instead.-const isInternalUserViaEmailCheck = () => {- const userEmail = getData(LS_KEYS.USER)?.email;- if (!userEmail) return false;-- return userEmail.endsWith("@ente.io");-};diff --git a/web/apps/photos/src/pages/_app.tsx b/web/apps/photos/src/pages/_app.tsxindex 36c43c7420..3cb82d3a94 100644--- a/web/apps/photos/src/pages/_app.tsx+++ b/web/apps/photos/src/pages/_app.tsx@@ -23,6 +23,7 @@ import { photosDialogZIndex } from "@/new/photos/components/utils/z-index";import DownloadManager from "@/new/photos/services/download";import { runMigrations } from "@/new/photos/services/migrations";import { initML, isMLSupported } from "@/new/photos/services/ml";+import { initSettings } from "@/new/photos/services/settings";import { AppContext } from "@/new/photos/types/context";import { Overlay } from "@ente/shared/components/Container";import DialogBox from "@ente/shared/components/DialogBox";@@ -100,6 +101,7 @@ export default function App({ Component, pageProps }: AppProps) {HTTPService.setHeaders({ "X-Client-Package": clientPackageName });logUnhandledErrorsAndRejections(true);void runMigrations();+ initSettings();return () => logUnhandledErrorsAndRejections(false);}, []);diff --git a/web/packages/new/photos/services/settings.ts b/web/packages/new/photos/services/settings.tsindex 9a42906a89..c759b4c4dd 100644--- a/web/packages/new/photos/services/settings.ts+++ b/web/packages/new/photos/services/settings.ts@@ -34,12 +34,15 @@ class SettingsState {/*** In-memory flag that tracks if the current user is an internal user.+ *+ * See: [Note: Remote flag lifecycle].*/isInternalUser = false;/*** In-memory flag that tracks if maps are enabled.*+ * See: [Note: Remote flag lifecycle].*/isMapEnabled = false;}@@ -102,7 +105,6 @@ let _state = new SettingsState();* for frequent use during UI rendering.** 5. Everything gets reset to the default state on {@link logoutSettings}.- **/export const triggerSettingsSyncIfNeeded = () => {if (!_state.haveSynced) void syncSettings();@@ -156,25 +158,13 @@ const FeatureFlags = z.object({type FeatureFlags = z.infer<typeof FeatureFlags>;-const remoteFeatureFlagsFetchingIfNeeded = async () => {- let ff = savedRemoteFeatureFlags();- if (!ff) {- try {- await syncSettings();- } catch (e) {- log.warn("Ignoring error when fetching feature flags", e);- }- ff = savedRemoteFeatureFlags();- }- return ff;-};-const readInMemoryFlagsFromLocalStorage = () => {const flags = savedRemoteFeatureFlags();- _state.isInternalUser = flags?.internalUser ?? isInternalUserViaEmail();+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing+ _state.isInternalUser = flags?.internalUser || isInternalUserViaEmail();};-export const isInternalUserViaEmail = () => {+const isInternalUserViaEmail = () => {const user = localUser();return !!user?.email.endsWith("@ente.io");};