From 0f5f488fc7d5eb1cf487d6289520dfd82332c23b Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Wed, 5 Jun 2024 13:58:17 +0530 Subject: [PATCH] Prune --- web/packages/accounts/pages/change-password.tsx | 6 +++--- web/packages/accounts/pages/generate.tsx | 9 ++++----- web/packages/accounts/pages/two-factor/setup.tsx | 6 +++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/web/packages/accounts/pages/change-password.tsx b/web/packages/accounts/pages/change-password.tsx index 2ecd09fd03..5b193e8e31 100644 --- a/web/packages/accounts/pages/change-password.tsx +++ b/web/packages/accounts/pages/change-password.tsx @@ -13,7 +13,7 @@ import { convertBase64ToBuffer, convertBufferToBase64, } from "@ente/accounts/utils"; -import { APP_HOMES, appNameToAppNameOld } from "@ente/shared/apps/constants"; +import { appNameToAppNameOld } from "@ente/shared/apps/constants"; import { VerticallyCentered } from "@ente/shared/components/Container"; import FormPaper from "@ente/shared/components/Form/FormPaper"; import FormPaperFooter from "@ente/shared/components/Form/FormPaper/Footer"; @@ -33,6 +33,7 @@ import type { KEK, KeyAttributes, User } from "@ente/shared/user/types"; import { t } from "i18next"; import { useRouter } from "next/router"; import { useEffect, useState } from "react"; +import { appHomeRoute } from "../services/redirect"; import type { PageProps } from "../types/page"; const Page: React.FC = ({ appContext }) => { @@ -126,8 +127,7 @@ const Page: React.FC = ({ appContext }) => { const redirectToAppHome = () => { setData(LS_KEYS.SHOW_BACK_BUTTON, { value: true }); - // TODO: Refactor the type of APP_HOMES to not require the ?? - router.push(APP_HOMES.get(appNameOld) ?? "/"); + router.push(appHomeRoute(appName)); }; // TODO: Handle the case where user is not loaded yet. diff --git a/web/packages/accounts/pages/generate.tsx b/web/packages/accounts/pages/generate.tsx index 3ce7293f6e..7062f3373d 100644 --- a/web/packages/accounts/pages/generate.tsx +++ b/web/packages/accounts/pages/generate.tsx @@ -7,7 +7,7 @@ import SetPasswordForm, { import { PAGES } from "@ente/accounts/constants/pages"; import { configureSRP } from "@ente/accounts/services/srp"; import { generateKeyAndSRPAttributes } from "@ente/accounts/utils/srp"; -import { APP_HOMES, appNameToAppNameOld } from "@ente/shared/apps/constants"; +import { appNameToAppNameOld } from "@ente/shared/apps/constants"; import { VerticallyCentered } from "@ente/shared/components/Container"; import EnteSpinner from "@ente/shared/components/EnteSpinner"; import FormPaper from "@ente/shared/components/Form/FormPaper"; @@ -29,6 +29,7 @@ import type { KeyAttributes, User } from "@ente/shared/user/types"; import { t } from "i18next"; import { useRouter } from "next/router"; import { useEffect, useState } from "react"; +import { appHomeRoute } from "../services/redirect"; import type { PageProps } from "../types/page"; const Page: React.FC = ({ appContext }) => { @@ -58,8 +59,7 @@ const Page: React.FC = ({ appContext }) => { setRecoveryModalView(true); setLoading(false); } else { - // TODO: Refactor the type of APP_HOMES to not require the ?? - router.push(APP_HOMES.get(appNameOld) ?? "/"); + router.push(appHomeRoute(appName)); } } else if (keyAttributes?.encryptedKey) { router.push(PAGES.CREDENTIALS); @@ -109,8 +109,7 @@ const Page: React.FC = ({ appContext }) => { show={recoverModalView} onHide={() => { setRecoveryModalView(false); - // TODO: Refactor the type of APP_HOMES to not require the ?? - router.push(APP_HOMES.get(appNameOld) ?? "/"); + router.push(appHomeRoute(appName)); }} /* TODO: Why is this error being ignored */ somethingWentWrong={() => {}} diff --git a/web/packages/accounts/pages/two-factor/setup.tsx b/web/packages/accounts/pages/two-factor/setup.tsx index 98887fcf04..635047d740 100644 --- a/web/packages/accounts/pages/two-factor/setup.tsx +++ b/web/packages/accounts/pages/two-factor/setup.tsx @@ -6,7 +6,7 @@ import VerifyTwoFactor, { } from "@ente/accounts/components/two-factor/VerifyForm"; import { TwoFactorSetup } from "@ente/accounts/components/two-factor/setup"; import type { TwoFactorSecret } from "@ente/accounts/types/user"; -import { APP_HOMES, appNameToAppNameOld } from "@ente/shared/apps/constants"; +import { appNameToAppNameOld } from "@ente/shared/apps/constants"; import { VerticallyCentered } from "@ente/shared/components/Container"; import LinkButton from "@ente/shared/components/LinkButton"; import { encryptWithRecoveryKey } from "@ente/shared/crypto/helpers"; @@ -16,6 +16,7 @@ import Card from "@mui/material/Card"; import { t } from "i18next"; import { useRouter } from "next/router"; import { useEffect, useState } from "react"; +import { appHomeRoute } from "../../services/redirect"; import type { PageProps } from "../../types/page"; export enum SetupMode { @@ -62,8 +63,7 @@ const Page: React.FC = ({ appContext }) => { ...getData(LS_KEYS.USER), isTwoFactorEnabled: true, }); - // TODO: Refactor the type of APP_HOMES to not require the ?? - router.push(APP_HOMES.get(appNameOld) ?? "/"); + router.push(appHomeRoute(appName)); }; return (