Skip to content

armgit / ente

Public Imported from GitHub
0

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

Start fixing lint issues

Manav Rathiaa6e5c923443
diff --git a/web/apps/photos/src/components/Sidebar/AdvancedSettings.tsx b/web/apps/photos/src/components/Sidebar/AdvancedSettings.tsx
index c580c6a758..1520845400 100644
--- a/web/apps/photos/src/components/Sidebar/AdvancedSettings.tsx
+++ b/web/apps/photos/src/components/Sidebar/AdvancedSettings.tsx
@@ -1,4 +1,4 @@
-import { MLSearchSettings } from "@/new/photos/components/MLSettings";
+import { MLSettings } from "@/new/photos/components/MLSettings";
import { EnteDrawer } from "@/new/shared/components/EnteDrawer";
import { MenuItemGroup, MenuSectionTitle } from "@/new/shared/components/Menu";
import { Titlebar } from "@/new/shared/components/Titlebar";
@@ -132,10 +132,11 @@ export default function AdvancedSettings({ open, onClose, onRootClose }) {
</Stack>
</Box>
</Stack>
- <MLSearchSettings
+ <MLSettings
open={mlSearchSettingsView}
onClose={closeMlSearchSettings}
onRootClose={handleRootClose}
+ appContext={appContext}
/>
</EnteDrawer>
);
diff --git a/web/packages/new/photos/components/MLSettings.tsx b/web/packages/new/photos/components/MLSettings.tsx
index 66eac5a578..8553ac0b75 100644
--- a/web/packages/new/photos/components/MLSettings.tsx
+++ b/web/packages/new/photos/components/MLSettings.tsx
@@ -15,7 +15,7 @@ import {
Box,
Button,
Checkbox,
- DialogProps,
+ type DialogProps,
FormControlLabel,
FormGroup,
Link,
@@ -23,17 +23,33 @@ import {
Typography,
} from "@mui/material";
import { t } from "i18next";
-import { AppContext } from "pages/_app";
-import { useContext, useEffect, useState } from "react";
+import React, { useEffect, useState } from "react";
import { Trans } from "react-i18next";
+import type { NewAppContextPhotos } from "../types/context";
-export const MLSearchSettings = ({ open, onClose, onRootClose }) => {
+interface MLSettingsProps {
+ /** If `true`, then the drawer page is shown. */
+ open: boolean;
+ /** Called when the user wants to go back from this drawer page. */
+ onClose: () => void;
+ /** Called when the user wants to close the containing drawer. */
+ onRootClose: () => void;
+ /** See: [Note: Migrating components that need the app context]. */
+ appContext: NewAppContextPhotos;
+}
+
+export const MLSettings: React.FC<MLSettingsProps> = ({
+ open,
+ onClose,
+ onRootClose,
+ appContext,
+}) => {
const {
setDialogMessage,
somethingWentWrong,
startLoading,
finishLoading,
- } = useContext(AppContext);
+ } = appContext;
const [enableFaceSearchView, setEnableFaceSearchView] = useState(false);
diff --git a/web/packages/new/photos/types/context.ts b/web/packages/new/photos/types/context.ts
new file mode 100644
index 0000000000..d864717146
--- /dev/null
+++ b/web/packages/new/photos/types/context.ts
@@ -0,0 +1,19 @@
+import type { SetDialogBoxAttributes } from "@ente/shared/components/DialogBox/types";
+
+/**
+ * A subset of the AppContext type used by the photos app.
+ *
+ * [Note: Migrating components that need the app context]
+ *
+ * This only exists to make it easier to migrate code into the @/new package.
+ * Once we move this code back (after TypeScript strict mode migration is done),
+ * then the code that uses this can start directly using the actual app context
+ * instead of needing to explicitly pass a prop of this type.
+ * */
+export interface NewAppContextPhotos {
+ startLoading: () => void;
+ finishLoading: () => void;
+ closeMessageDialog: () => void;
+ setDialogMessage: SetDialogBoxAttributes;
+ somethingWentWrong: () => void;
+}