Skip to content

armgit / ente

Public Imported from GitHub
0

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

Scope

Manav Rathicd81bbe19e20
diff --git a/web/apps/accounts/src/types/context.ts b/web/apps/accounts/src/types/context.ts
index c718471dba..18716db085 100644
--- a/web/apps/accounts/src/types/context.ts
+++ b/web/apps/accounts/src/types/context.ts
@@ -1,5 +1,5 @@
-import type { BaseAppContextT } from "@/next/types/context";
import { ensure } from "@/utils/ensure";
+import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
import { createContext, useContext } from "react";
/**
@@ -9,7 +9,12 @@ import { createContext, useContext } from "react";
*
* - It also doesn't need the logout function.
*/
-type AppContextT = Omit<BaseAppContextT, "logout">;
+interface AppContextT {
+ /** Show or hide the app's navigation bar. */
+ showNavBar: (show: boolean) => void;
+ isMobile: boolean;
+ setDialogBoxAttributesV2: (attrs: DialogBoxAttributesV2) => void;
+}
/**
* The React {@link Context} available to all pages.
diff --git a/web/apps/auth/src/pages/_app.tsx b/web/apps/auth/src/pages/_app.tsx
index a18bb5c130..113d851dc2 100644
--- a/web/apps/auth/src/pages/_app.tsx
+++ b/web/apps/auth/src/pages/_app.tsx
@@ -5,9 +5,9 @@ import {
logStartupBanner,
logUnhandledErrorsAndRejections,
} from "@/next/log-web";
-import type { BaseAppContextT } from "@/next/types/context";
import { ensure } from "@/utils/ensure";
import { accountLogout } from "@ente/accounts/services/logout";
+import type { AccountsContextT } from "@ente/accounts/types/context";
import { Overlay } from "@ente/shared/components/Container";
import DialogBoxV2 from "@ente/shared/components/DialogBoxV2";
import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
@@ -37,9 +37,9 @@ import LoadingBar, { type LoadingBarRef } from "react-top-loading-bar";
import "../../public/css/global.css";
/**
- * Properties available via the {@link AppContext} to the Auth app's React tree.
+ * Properties available via {@link AppContext} to the Auth app's React tree.
*/
-type AppContextT = BaseAppContextT & {
+type AppContextT = AccountsContextT & {
startLoading: () => void;
finishLoading: () => void;
themeColor: THEME_COLOR;
diff --git a/web/apps/photos/src/pages/_app.tsx b/web/apps/photos/src/pages/_app.tsx
index c90c4092de..d000858522 100644
--- a/web/apps/photos/src/pages/_app.tsx
+++ b/web/apps/photos/src/pages/_app.tsx
@@ -6,9 +6,9 @@ import {
logStartupBanner,
logUnhandledErrorsAndRejections,
} from "@/next/log-web";
-import type { BaseAppContextT } from "@/next/types/context";
import { AppUpdate } from "@/next/types/ipc";
import { ensure } from "@/utils/ensure";
+import type { AccountsContextT } from "@ente/accounts/types/context";
import { Overlay } from "@ente/shared/components/Container";
import DialogBox from "@ente/shared/components/DialogBox";
import {
@@ -73,10 +73,9 @@ const redirectMap = new Map([
]);
/**
- * Properties available via the {@link AppContext} to the Photos app's React
- * tree.
+ * Properties available via {@link AppContext} to the Photos app's React tree.
*/
-type AppContextT = BaseAppContextT & {
+type AppContextT = AccountsContextT & {
mlSearchEnabled: boolean;
mapEnabled: boolean;
updateMlSearchEnabled: (enabled: boolean) => Promise<void>;
diff --git a/web/packages/accounts/pages/two-factor/recover.tsx b/web/packages/accounts/pages/two-factor/recover.tsx
index 011f3fc80f..030281dcb0 100644
--- a/web/packages/accounts/pages/two-factor/recover.tsx
+++ b/web/packages/accounts/pages/two-factor/recover.tsx
@@ -1,5 +1,4 @@
import log from "@/next/log";
-import type { BaseAppContextT } from "@/next/types/context";
import { ensure } from "@/utils/ensure";
import {
recoverTwoFactor,
@@ -7,6 +6,7 @@ import {
type TwoFactorType,
} from "@ente/accounts/api/user";
import { PAGES } from "@ente/accounts/constants/pages";
+import type { AccountsContextT } from "@ente/accounts/types/context";
import { VerticallyCentered } from "@ente/shared/components/Container";
import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
import FormPaper from "@ente/shared/components/Form/FormPaper";
@@ -38,7 +38,7 @@ const bip39 = require("bip39");
bip39.setDefaultWordlist("english");
export interface RecoverPageProps {
- appContext: BaseAppContextT;
+ appContext: AccountsContextT;
twoFactorType: TwoFactorType;
}
diff --git a/web/packages/accounts/types/page.ts b/web/packages/accounts/types/page.ts
index c673f8a47e..c1c5d54548 100644
--- a/web/packages/accounts/types/page.ts
+++ b/web/packages/accounts/types/page.ts
@@ -1,4 +1,4 @@
-import type { BaseAppContextT } from "@/next/types/context";
+import type { AccountsContextT } from "@ente/accounts/types/context";
/**
* The default type for pages exposed by this package.
@@ -12,5 +12,5 @@ export interface PageProps {
* Within this package we do not have access to the context object declared
* with the app's code, so we need to take the context as a parameter.
*/
- appContext: BaseAppContextT;
+ appContext: AccountsContextT;
}
diff --git a/web/packages/next/app.ts b/web/packages/next/app.ts
index ae055db4a1..89cd492c09 100644
--- a/web/packages/next/app.ts
+++ b/web/packages/next/app.ts
@@ -1,5 +1,3 @@
-import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
-
export const appNames = ["accounts", "auth", "cast", "photos"] as const;
/**
@@ -70,16 +68,3 @@ export const clientPackageName = (() => {
photos: "io.ente.photos.web",
}[appName];
})();
-
-/**
- * Properties guaranteed to be present in the AppContext types for apps that are
- * listed in {@link AppName}.
- */
-export interface BaseAppContextT {
- /** Perform the (possibly app specific) logout sequence. */
- logout: () => void;
- /** Show or hide the app's navigation bar. */
- showNavBar: (show: boolean) => void;
- isMobile: boolean;
- setDialogBoxAttributesV2: (attrs: DialogBoxAttributesV2) => void;
-}
diff --git a/web/packages/shared/components/LoginComponents.tsx b/web/packages/shared/components/LoginComponents.tsx
index cd5402654b..c3ea97d1f7 100644
--- a/web/packages/shared/components/LoginComponents.tsx
+++ b/web/packages/shared/components/LoginComponents.tsx
@@ -1,6 +1,5 @@
import log from "@/next/log";
import { customAPIHost } from "@/next/origins";
-import type { BaseAppContextT } from "@/next/types/context";
import {
checkPasskeyVerificationStatus,
passkeySessionExpiredErrorMessage,
@@ -74,23 +73,18 @@ interface VerifyingPasskeyProps {
email: string | undefined;
/** Called when the user wants to redirect again. */
onRetry: () => void;
- /**
- * The appContext.
- *
- * Needs to be explicitly passed since this component is used in a package
- * where the pages are not wrapped in the provider.
- */
- appContext: BaseAppContextT;
+ /** Perform the (possibly app specific) logout sequence. */
+ logout: () => void;
+ setDialogBoxAttributesV2: (attrs: DialogBoxAttributesV2) => void;
}
export const VerifyingPasskey: React.FC<VerifyingPasskeyProps> = ({
passkeySessionID,
email,
onRetry,
- appContext,
+ logout,
+ setDialogBoxAttributesV2,
}) => {
- const { logout, setDialogBoxAttributesV2 } = appContext;
-
type VerificationStatus = "waiting" | "checking" | "pending";
const [verificationStatus, setVerificationStatus] =
useState<VerificationStatus>("waiting");