Browse Source

Fix dialog

Manav Rathi 1 year ago
parent
commit
1548bcd378

+ 6 - 9
web/apps/accounts/src/pages/_app.tsx

@@ -6,10 +6,7 @@ import { accountLogout } from "@ente/accounts/services/logout";
 import { APPS, APP_TITLES } from "@ente/shared/apps/constants";
 import { APPS, APP_TITLES } from "@ente/shared/apps/constants";
 import { Overlay } from "@ente/shared/components/Container";
 import { Overlay } from "@ente/shared/components/Container";
 import DialogBoxV2 from "@ente/shared/components/DialogBoxV2";
 import DialogBoxV2 from "@ente/shared/components/DialogBoxV2";
-import type {
-    DialogBoxAttributesV2,
-    SetDialogBoxAttributesV2,
-} from "@ente/shared/components/DialogBoxV2/types";
+import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
 import EnteSpinner from "@ente/shared/components/EnteSpinner";
 import EnteSpinner from "@ente/shared/components/EnteSpinner";
 import { AppNavbar } from "@ente/shared/components/Navbar/app";
 import { AppNavbar } from "@ente/shared/components/Navbar/app";
 import { useLocalState } from "@ente/shared/hooks/useLocalState";
 import { useLocalState } from "@ente/shared/hooks/useLocalState";
@@ -28,7 +25,7 @@ import "styles/global.css";
 interface AppContextProps {
 interface AppContextProps {
     isMobile: boolean;
     isMobile: boolean;
     showNavBar: (show: boolean) => void;
     showNavBar: (show: boolean) => void;
-    setDialogBoxAttributesV2: SetDialogBoxAttributesV2;
+    setDialogBoxAttributesV2: (attrs: DialogBoxAttributesV2) => void;
     logout: () => void;
     logout: () => void;
 }
 }
 
 
@@ -39,8 +36,9 @@ export default function App({ Component, pageProps }: AppProps) {
 
 
     const [showNavbar, setShowNavBar] = useState(false);
     const [showNavbar, setShowNavBar] = useState(false);
 
 
-    const [dialogBoxAttributeV2, setDialogBoxAttributesV2] =
-        useState<DialogBoxAttributesV2>();
+    const [dialogBoxAttributeV2, setDialogBoxAttributesV2] = useState<
+        DialogBoxAttributesV2 | undefined
+    >();
 
 
     const [dialogBoxV2View, setDialogBoxV2View] = useState(false);
     const [dialogBoxV2View, setDialogBoxV2View] = useState(false);
 
 
@@ -106,8 +104,7 @@ export default function App({ Component, pageProps }: AppProps) {
                     value={{
                     value={{
                         isMobile,
                         isMobile,
                         showNavBar,
                         showNavBar,
-                        setDialogBoxAttributesV2:
-                            setDialogBoxAttributesV2 as any,
+                        setDialogBoxAttributesV2,
                         logout,
                         logout,
                     }}
                     }}
                 >
                 >

+ 5 - 7
web/apps/auth/src/pages/_app.tsx

@@ -12,10 +12,7 @@ import {
 } from "@ente/shared/apps/constants";
 } from "@ente/shared/apps/constants";
 import { Overlay } from "@ente/shared/components/Container";
 import { Overlay } from "@ente/shared/components/Container";
 import DialogBoxV2 from "@ente/shared/components/DialogBoxV2";
 import DialogBoxV2 from "@ente/shared/components/DialogBoxV2";
-import type {
-    DialogBoxAttributesV2,
-    SetDialogBoxAttributesV2,
-} from "@ente/shared/components/DialogBoxV2/types";
+import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
 import EnteSpinner from "@ente/shared/components/EnteSpinner";
 import EnteSpinner from "@ente/shared/components/EnteSpinner";
 import { MessageContainer } from "@ente/shared/components/MessageContainer";
 import { MessageContainer } from "@ente/shared/components/MessageContainer";
 import { AppNavbar } from "@ente/shared/components/Navbar/app";
 import { AppNavbar } from "@ente/shared/components/Navbar/app";
@@ -43,7 +40,7 @@ type AppContextType = {
     themeColor: THEME_COLOR;
     themeColor: THEME_COLOR;
     setThemeColor: (themeColor: THEME_COLOR) => void;
     setThemeColor: (themeColor: THEME_COLOR) => void;
     somethingWentWrong: () => void;
     somethingWentWrong: () => void;
-    setDialogBoxAttributesV2: SetDialogBoxAttributesV2;
+    setDialogBoxAttributesV2: (attrs: DialogBoxAttributesV2) => void;
     logout: () => void;
     logout: () => void;
 };
 };
 
 
@@ -59,8 +56,9 @@ export default function App({ Component, pageProps }: AppProps) {
     const [showNavbar, setShowNavBar] = useState(false);
     const [showNavbar, setShowNavBar] = useState(false);
     const isLoadingBarRunning = useRef<boolean>(false);
     const isLoadingBarRunning = useRef<boolean>(false);
     const loadingBar = useRef<LoadingBarRef>(null);
     const loadingBar = useRef<LoadingBarRef>(null);
-    const [dialogBoxAttributeV2, setDialogBoxAttributesV2] =
-        useState<DialogBoxAttributesV2>({});
+    const [dialogBoxAttributeV2, setDialogBoxAttributesV2] = useState<
+        DialogBoxAttributesV2 | undefined
+    >();
     const [dialogBoxV2View, setDialogBoxV2View] = useState(false);
     const [dialogBoxV2View, setDialogBoxV2View] = useState(false);
     const isMobile = useMediaQuery("(max-width:428px)");
     const isMobile = useMediaQuery("(max-width:428px)");
     const [themeColor, setThemeColor] = useLocalState(
     const [themeColor, setThemeColor] = useLocalState(

+ 5 - 7
web/apps/photos/src/pages/_app.tsx

@@ -18,10 +18,7 @@ import {
     SetDialogBoxAttributes,
     SetDialogBoxAttributes,
 } from "@ente/shared/components/DialogBox/types";
 } from "@ente/shared/components/DialogBox/types";
 import DialogBoxV2 from "@ente/shared/components/DialogBoxV2";
 import DialogBoxV2 from "@ente/shared/components/DialogBoxV2";
-import type {
-    DialogBoxAttributesV2,
-    SetDialogBoxAttributesV2,
-} from "@ente/shared/components/DialogBoxV2/types";
+import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
 import EnteSpinner from "@ente/shared/components/EnteSpinner";
 import EnteSpinner from "@ente/shared/components/EnteSpinner";
 import { MessageContainer } from "@ente/shared/components/MessageContainer";
 import { MessageContainer } from "@ente/shared/components/MessageContainer";
 import { AppNavbar } from "@ente/shared/components/Navbar/app";
 import { AppNavbar } from "@ente/shared/components/Navbar/app";
@@ -96,7 +93,7 @@ type AppContextType = {
     themeColor: THEME_COLOR;
     themeColor: THEME_COLOR;
     setThemeColor: (themeColor: THEME_COLOR) => void;
     setThemeColor: (themeColor: THEME_COLOR) => void;
     somethingWentWrong: () => void;
     somethingWentWrong: () => void;
-    setDialogBoxAttributesV2: SetDialogBoxAttributesV2;
+    setDialogBoxAttributesV2: (attrs: DialogBoxAttributesV2) => void;
     isCFProxyDisabled: boolean;
     isCFProxyDisabled: boolean;
     setIsCFProxyDisabled: (disabled: boolean) => void;
     setIsCFProxyDisabled: (disabled: boolean) => void;
     logout: () => void;
     logout: () => void;
@@ -118,8 +115,9 @@ export default function App({ Component, pageProps }: AppProps) {
     const isLoadingBarRunning = useRef(false);
     const isLoadingBarRunning = useRef(false);
     const loadingBar = useRef(null);
     const loadingBar = useRef(null);
     const [dialogMessage, setDialogMessage] = useState<DialogBoxAttributes>();
     const [dialogMessage, setDialogMessage] = useState<DialogBoxAttributes>();
-    const [dialogBoxAttributeV2, setDialogBoxAttributesV2] =
-        useState<DialogBoxAttributesV2>();
+    const [dialogBoxAttributeV2, setDialogBoxAttributesV2] = useState<
+        DialogBoxAttributesV2 | undefined
+    >();
     useState<DialogBoxAttributes>(null);
     useState<DialogBoxAttributes>(null);
     const [messageDialogView, setMessageDialogView] = useState(false);
     const [messageDialogView, setMessageDialogView] = useState(false);
     const [dialogBoxV2View, setDialogBoxV2View] = useState(false);
     const [dialogBoxV2View, setDialogBoxV2View] = useState(false);

+ 2 - 2
web/packages/shared/apps/types.ts

@@ -1,12 +1,12 @@
 import { TwoFactorType } from "@ente/accounts/constants/twofactor";
 import { TwoFactorType } from "@ente/accounts/constants/twofactor";
-import type { SetDialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
+import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
 import { APPS } from "./constants";
 import { APPS } from "./constants";
 
 
 export interface PageProps {
 export interface PageProps {
     appContext: {
     appContext: {
         showNavBar: (show: boolean) => void;
         showNavBar: (show: boolean) => void;
         isMobile: boolean;
         isMobile: boolean;
-        setDialogBoxAttributesV2: SetDialogBoxAttributesV2;
+        setDialogBoxAttributesV2: (attrs: DialogBoxAttributesV2) => void;
         logout: () => void;
         logout: () => void;
     };
     };
     appName: APPS;
     appName: APPS;

+ 1 - 1
web/packages/shared/components/DialogBoxV2/index.tsx

@@ -15,7 +15,7 @@ import type { DialogBoxAttributesV2 } from "./types";
 type IProps = React.PropsWithChildren<
 type IProps = React.PropsWithChildren<
     Omit<DialogProps, "onClose"> & {
     Omit<DialogProps, "onClose"> & {
         onClose: () => void;
         onClose: () => void;
-        attributes: DialogBoxAttributesV2;
+        attributes?: DialogBoxAttributesV2;
     }
     }
 >;
 >;
 
 

+ 0 - 4
web/packages/shared/components/DialogBoxV2/types.ts

@@ -39,7 +39,3 @@ export interface DialogBoxAttributesV2 {
     }[];
     }[];
     buttonDirection?: "row" | "column";
     buttonDirection?: "row" | "column";
 }
 }
-
-export type SetDialogBoxAttributesV2 = React.Dispatch<
-    React.SetStateAction<DialogBoxAttributesV2>
->;