Skip to content

armgit / ente

Public Imported from GitHub
0

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

Make the context more specific

Manav Rathi39a6b3cd6b37
diff --git a/web/apps/accounts/src/pages/_app.tsx b/web/apps/accounts/src/pages/_app.tsx
index 3bad33005b..db75769166 100644
--- a/web/apps/accounts/src/pages/_app.tsx
+++ b/web/apps/accounts/src/pages/_app.tsx
@@ -36,9 +36,9 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {
useEffect(() => {
disableDiskLogs();
- // accounts.ente.io has no local state, but some older builds might've
- // leftover some scraps. Clear it out. (tag: Migration)
- // Added 1 July 2024, can be removed after a while.
+ // The accounts app has no local state, but some older builds might've
+ // leftover some scraps. Clear it out. Thi code added 1 July 2024, can
+ // be removed after a while (tag: Migration).
clearData();
void setupI18n().finally(() => setIsI18nReady(true));
logUnhandledErrorsAndRejections(true);
diff --git a/web/apps/accounts/src/components/context.ts b/web/apps/accounts/src/types/context.ts
similarity index 57%
rename from web/apps/accounts/src/components/context.ts
rename to web/apps/accounts/src/types/context.ts
index 3189659b03..c718471dba 100644
--- a/web/apps/accounts/src/components/context.ts
+++ b/web/apps/accounts/src/types/context.ts
@@ -2,10 +2,18 @@ import type { BaseAppContextT } from "@/next/types/context";
import { ensure } from "@/utils/ensure";
import { createContext, useContext } from "react";
-/** The accounts app has no extra properties on top of the base context. */
-type AppContextT = BaseAppContextT;
+/**
+ * The type of the context for pages in the accounts app.
+ *
+ * - The accounts app has no extra properties on top of the base context.
+ *
+ * - It also doesn't need the logout function.
+ */
+type AppContextT = Omit<BaseAppContextT, "logout">;
-/** The React {@link Context} available to all pages. */
+/**
+ * The React {@link Context} available to all pages.
+ */
export const AppContext = createContext<AppContextT | undefined>(undefined);
/**
diff --git a/web/packages/accounts/README.md b/web/packages/accounts/README.md
new file mode 100644
index 0000000000..3c4bcfddc6
--- /dev/null
+++ b/web/packages/accounts/README.md
@@ -0,0 +1,15 @@
+## @ente/accounts
+
+A package for sharing the pages involved in the signup/login flow.
+
+Currently this is used by the photos and auth apps.
+
+> [!NOTE]
+>
+> This is distinct from the accounts _app_, which currently acts as a broker for
+> passkeys.
+
+### Packaging
+
+This (internal) package exports a React TypeScript library. We rely on the
+importing project to transpile and bundle it.
diff --git a/web/packages/next/types/context.ts b/web/packages/accounts/types/context.ts
similarity index 68%
rename from web/packages/next/types/context.ts
rename to web/packages/accounts/types/context.ts
index 59d3724ff2..38a49dc4ee 100644
--- a/web/packages/next/types/context.ts
+++ b/web/packages/accounts/types/context.ts
@@ -1,10 +1,10 @@
import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
/**
- * Properties guaranteed to be present in the AppContext types for apps that are
- * listed in {@link AppName}.
+ * Properties expected to be present in the AppContext types for pages that
+ * defer to the pages provided by the accounts package.
*/
-export interface BaseAppContextT {
+export interface AccountsContextT {
/** Perform the (possibly app specific) logout sequence. */
logout: () => void;
/** Show or hide the app's navigation bar. */