From 1548bcd37808af9b8ae85c6732b89a607bbac765 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 25 May 2024 20:24:55 +0530 Subject: [PATCH] Fix dialog --- web/apps/accounts/src/pages/_app.tsx | 15 ++++++--------- web/apps/auth/src/pages/_app.tsx | 12 +++++------- web/apps/photos/src/pages/_app.tsx | 12 +++++------- web/packages/shared/apps/types.ts | 4 ++-- .../shared/components/DialogBoxV2/index.tsx | 2 +- .../shared/components/DialogBoxV2/types.ts | 4 ---- 6 files changed, 19 insertions(+), 30 deletions(-) diff --git a/web/apps/accounts/src/pages/_app.tsx b/web/apps/accounts/src/pages/_app.tsx index e08aacb3f..f2ef890b4 100644 --- a/web/apps/accounts/src/pages/_app.tsx +++ b/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 { Overlay } from "@ente/shared/components/Container"; 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 { AppNavbar } from "@ente/shared/components/Navbar/app"; import { useLocalState } from "@ente/shared/hooks/useLocalState"; @@ -28,7 +25,7 @@ import "styles/global.css"; interface AppContextProps { isMobile: boolean; showNavBar: (show: boolean) => void; - setDialogBoxAttributesV2: SetDialogBoxAttributesV2; + setDialogBoxAttributesV2: (attrs: DialogBoxAttributesV2) => void; logout: () => void; } @@ -39,8 +36,9 @@ export default function App({ Component, pageProps }: AppProps) { const [showNavbar, setShowNavBar] = useState(false); - const [dialogBoxAttributeV2, setDialogBoxAttributesV2] = - useState(); + const [dialogBoxAttributeV2, setDialogBoxAttributesV2] = useState< + DialogBoxAttributesV2 | undefined + >(); const [dialogBoxV2View, setDialogBoxV2View] = useState(false); @@ -106,8 +104,7 @@ export default function App({ Component, pageProps }: AppProps) { value={{ isMobile, showNavBar, - setDialogBoxAttributesV2: - setDialogBoxAttributesV2 as any, + setDialogBoxAttributesV2, logout, }} > diff --git a/web/apps/auth/src/pages/_app.tsx b/web/apps/auth/src/pages/_app.tsx index bf1167ee2..a01b8fb8d 100644 --- a/web/apps/auth/src/pages/_app.tsx +++ b/web/apps/auth/src/pages/_app.tsx @@ -12,10 +12,7 @@ import { } from "@ente/shared/apps/constants"; import { Overlay } from "@ente/shared/components/Container"; 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 { MessageContainer } from "@ente/shared/components/MessageContainer"; import { AppNavbar } from "@ente/shared/components/Navbar/app"; @@ -43,7 +40,7 @@ type AppContextType = { themeColor: THEME_COLOR; setThemeColor: (themeColor: THEME_COLOR) => void; somethingWentWrong: () => void; - setDialogBoxAttributesV2: SetDialogBoxAttributesV2; + setDialogBoxAttributesV2: (attrs: DialogBoxAttributesV2) => void; logout: () => void; }; @@ -59,8 +56,9 @@ export default function App({ Component, pageProps }: AppProps) { const [showNavbar, setShowNavBar] = useState(false); const isLoadingBarRunning = useRef(false); const loadingBar = useRef(null); - const [dialogBoxAttributeV2, setDialogBoxAttributesV2] = - useState({}); + const [dialogBoxAttributeV2, setDialogBoxAttributesV2] = useState< + DialogBoxAttributesV2 | undefined + >(); const [dialogBoxV2View, setDialogBoxV2View] = useState(false); const isMobile = useMediaQuery("(max-width:428px)"); const [themeColor, setThemeColor] = useLocalState( diff --git a/web/apps/photos/src/pages/_app.tsx b/web/apps/photos/src/pages/_app.tsx index d9df703b7..0c8084c59 100644 --- a/web/apps/photos/src/pages/_app.tsx +++ b/web/apps/photos/src/pages/_app.tsx @@ -18,10 +18,7 @@ import { SetDialogBoxAttributes, } from "@ente/shared/components/DialogBox/types"; 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 { MessageContainer } from "@ente/shared/components/MessageContainer"; import { AppNavbar } from "@ente/shared/components/Navbar/app"; @@ -96,7 +93,7 @@ type AppContextType = { themeColor: THEME_COLOR; setThemeColor: (themeColor: THEME_COLOR) => void; somethingWentWrong: () => void; - setDialogBoxAttributesV2: SetDialogBoxAttributesV2; + setDialogBoxAttributesV2: (attrs: DialogBoxAttributesV2) => void; isCFProxyDisabled: boolean; setIsCFProxyDisabled: (disabled: boolean) => void; logout: () => void; @@ -118,8 +115,9 @@ export default function App({ Component, pageProps }: AppProps) { const isLoadingBarRunning = useRef(false); const loadingBar = useRef(null); const [dialogMessage, setDialogMessage] = useState(); - const [dialogBoxAttributeV2, setDialogBoxAttributesV2] = - useState(); + const [dialogBoxAttributeV2, setDialogBoxAttributesV2] = useState< + DialogBoxAttributesV2 | undefined + >(); useState(null); const [messageDialogView, setMessageDialogView] = useState(false); const [dialogBoxV2View, setDialogBoxV2View] = useState(false); diff --git a/web/packages/shared/apps/types.ts b/web/packages/shared/apps/types.ts index 4c189ee0e..6c6e4fe1a 100644 --- a/web/packages/shared/apps/types.ts +++ b/web/packages/shared/apps/types.ts @@ -1,12 +1,12 @@ 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"; export interface PageProps { appContext: { showNavBar: (show: boolean) => void; isMobile: boolean; - setDialogBoxAttributesV2: SetDialogBoxAttributesV2; + setDialogBoxAttributesV2: (attrs: DialogBoxAttributesV2) => void; logout: () => void; }; appName: APPS; diff --git a/web/packages/shared/components/DialogBoxV2/index.tsx b/web/packages/shared/components/DialogBoxV2/index.tsx index a0e226c87..aa0173156 100644 --- a/web/packages/shared/components/DialogBoxV2/index.tsx +++ b/web/packages/shared/components/DialogBoxV2/index.tsx @@ -15,7 +15,7 @@ import type { DialogBoxAttributesV2 } from "./types"; type IProps = React.PropsWithChildren< Omit & { onClose: () => void; - attributes: DialogBoxAttributesV2; + attributes?: DialogBoxAttributesV2; } >; diff --git a/web/packages/shared/components/DialogBoxV2/types.ts b/web/packages/shared/components/DialogBoxV2/types.ts index dbb5b11a2..f2ac31f0b 100644 --- a/web/packages/shared/components/DialogBoxV2/types.ts +++ b/web/packages/shared/components/DialogBoxV2/types.ts @@ -39,7 +39,3 @@ export interface DialogBoxAttributesV2 { }[]; buttonDirection?: "row" | "column"; } - -export type SetDialogBoxAttributesV2 = React.Dispatch< - React.SetStateAction ->;