Fix lint errors

This commit is contained in:
Manav Rathi 2024-04-05 20:58:13 +05:30
parent 8764e5cf4d
commit 411984ebdc
No known key found for this signature in database
42 changed files with 63 additions and 282 deletions

View file

@ -1,17 +1,9 @@
import CredentialPage from "@ente/accounts/pages/credentials";
import { APPS } from "@ente/shared/apps/constants";
import { useRouter } from "next/router";
import { useContext } from "react";
import { AppContext } from "../_app";
export default function Credential() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<CredentialPage
appContext={appContext}
router={router}
appName={APPS.ACCOUNTS}
/>
);
return <CredentialPage appContext={appContext} appName={APPS.ACCOUNTS} />;
}

View file

@ -1,17 +1,9 @@
import GeneratePage from "@ente/accounts/pages/generate";
import { APPS } from "@ente/shared/apps/constants";
import { useRouter } from "next/router";
import { AppContext } from "pages/_app";
import { useContext } from "react";
export default function Generate() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<GeneratePage
appContext={appContext}
router={router}
appName={APPS.ACCOUNTS}
/>
);
return <GeneratePage appContext={appContext} appName={APPS.ACCOUNTS} />;
}

View file

@ -1,17 +1,9 @@
import LoginPage from "@ente/accounts/pages/login";
import { APPS } from "@ente/shared/apps/constants";
import { useRouter } from "next/router";
import { useContext } from "react";
import { AppContext } from "../_app";
export default function Login() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<LoginPage
appContext={appContext}
router={router}
appName={APPS.ACCOUNTS}
/>
);
return <LoginPage appContext={appContext} appName={APPS.ACCOUNTS} />;
}

View file

@ -1,17 +1,14 @@
import { TwoFactorType } from "@ente/accounts/constants/twofactor";
import RecoverPage from "@ente/accounts/pages/recover";
import { APPS } from "@ente/shared/apps/constants";
import { useRouter } from "next/router";
import { AppContext } from "pages/_app";
import { useContext } from "react";
export default function Recover() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<RecoverPage
appContext={appContext}
router={router}
appName={APPS.PHOTOS}
twoFactorType={TwoFactorType.PASSKEY}
/>

View file

@ -7,11 +7,5 @@ import { useContext } from "react";
export default function Recover() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<RecoverPage
appContext={appContext}
router={router}
appName={APPS.ACCOUNTS}
/>
);
return <RecoverPage appContext={appContext} appName={APPS.ACCOUNTS} />;
}

View file

@ -1,17 +1,9 @@
import SignupPage from "@ente/accounts/pages/signup";
import { APPS } from "@ente/shared/apps/constants";
import { useRouter } from "next/router";
import { AppContext } from "pages/_app";
import { useContext } from "react";
export default function Sigup() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<SignupPage
appContext={appContext}
router={router}
appName={APPS.ACCOUNTS}
/>
);
return <SignupPage appContext={appContext} appName={APPS.ACCOUNTS} />;
}

View file

@ -8,10 +8,6 @@ export default function TwoFactorRecover() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<TwoFactorRecoverPage
appContext={appContext}
router={router}
appName={APPS.ACCOUNTS}
/>
<TwoFactorRecoverPage appContext={appContext} appName={APPS.ACCOUNTS} />
);
}

View file

@ -1,17 +1,11 @@
import TwoFactorSetupPage from "@ente/accounts/pages/two-factor/setup";
import { APPS } from "@ente/shared/apps/constants";
import { useRouter } from "next/router";
import { AppContext } from "pages/_app";
import { useContext } from "react";
export default function TwoFactorSetup() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<TwoFactorSetupPage
appContext={appContext}
router={router}
appName={APPS.ACCOUNTS}
/>
<TwoFactorSetupPage appContext={appContext} appName={APPS.ACCOUNTS} />
);
}

View file

@ -1,17 +1,11 @@
import TwoFactorVerifyPage from "@ente/accounts/pages/two-factor/verify";
import { APPS } from "@ente/shared/apps/constants";
import { useRouter } from "next/router";
import { AppContext } from "pages/_app";
import { useContext } from "react";
export default function TwoFactorVerify() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<TwoFactorVerifyPage
appContext={appContext}
router={router}
appName={APPS.ACCOUNTS}
/>
<TwoFactorVerifyPage appContext={appContext} appName={APPS.ACCOUNTS} />
);
}

View file

@ -7,11 +7,5 @@ import { useContext } from "react";
export default function Verify() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<VerifyPage
appContext={appContext}
router={router}
appName={APPS.ACCOUNTS}
/>
);
return <VerifyPage appContext={appContext} appName={APPS.ACCOUNTS} />;
}

View file

@ -1,17 +1,9 @@
import { APPS } from "@ente/shared/apps/constants";
import NotFoundPage from "@ente/shared/next/pages/404";
import { useRouter } from "next/router";
import { AppContext } from "pages/_app";
import { useContext } from "react";
export default function NotFound() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<NotFoundPage
appContext={appContext}
router={router}
appName={APPS.AUTH}
/>
);
return <NotFoundPage appContext={appContext} appName={APPS.AUTH} />;
}

View file

@ -1,17 +1,9 @@
import ChangeEmailPage from "@ente/accounts/pages/change-email";
import { APPS } from "@ente/shared/apps/constants";
import { useRouter } from "next/router";
import { AppContext } from "pages/_app";
import { useContext } from "react";
export default function ChangeEmail() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<ChangeEmailPage
appContext={appContext}
router={router}
appName={APPS.AUTH}
/>
);
return <ChangeEmailPage appContext={appContext} appName={APPS.AUTH} />;
}

View file

@ -7,11 +7,5 @@ import { useContext } from "react";
export default function ChangePassword() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<ChangePasswordPage
appContext={appContext}
router={router}
appName={APPS.AUTH}
/>
);
return <ChangePasswordPage appContext={appContext} appName={APPS.AUTH} />;
}

View file

@ -1,17 +1,9 @@
import CredentialPage from "@ente/accounts/pages/credentials";
import { APPS } from "@ente/shared/apps/constants";
import { useRouter } from "next/router";
import { AppContext } from "pages/_app";
import { useContext } from "react";
export default function Credential() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<CredentialPage
appContext={appContext}
router={router}
appName={APPS.AUTH}
/>
);
return <CredentialPage appContext={appContext} appName={APPS.AUTH} />;
}

View file

@ -1,17 +1,9 @@
import GeneratePage from "@ente/accounts/pages/generate";
import { APPS } from "@ente/shared/apps/constants";
import { useRouter } from "next/router";
import { AppContext } from "pages/_app";
import { useContext } from "react";
export default function Generate() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<GeneratePage
appContext={appContext}
router={router}
appName={APPS.AUTH}
/>
);
return <GeneratePage appContext={appContext} appName={APPS.AUTH} />;
}

View file

@ -7,11 +7,5 @@ import { useContext } from "react";
export default function Login() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<LoginPage
appContext={appContext}
router={router}
appName={APPS.AUTH}
/>
);
return <LoginPage appContext={appContext} appName={APPS.AUTH} />;
}

View file

@ -6,12 +6,5 @@ import { useContext } from "react";
export default function Recover() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<RecoverPage
appContext={appContext}
router={router}
appName={APPS.AUTH}
/>
);
return <RecoverPage appContext={appContext} appName={APPS.AUTH} />;
}

View file

@ -7,11 +7,5 @@ import { useContext } from "react";
export default function Sigup() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<SignupPage
appContext={appContext}
router={router}
appName={APPS.AUTH}
/>
);
return <SignupPage appContext={appContext} appName={APPS.AUTH} />;
}

View file

@ -1,17 +1,9 @@
import TwoFactorRecoverPage from "@ente/accounts/pages/two-factor/recover";
import { APPS } from "@ente/shared/apps/constants";
import { useRouter } from "next/router";
import { AppContext } from "pages/_app";
import { useContext } from "react";
export default function TwoFactorRecover() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<TwoFactorRecoverPage
appContext={appContext}
router={router}
appName={APPS.AUTH}
/>
);
return <TwoFactorRecoverPage appContext={appContext} appName={APPS.AUTH} />;
}

View file

@ -7,11 +7,5 @@ import { useContext } from "react";
export default function TwoFactorSetup() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<TwoFactorSetupPage
appContext={appContext}
router={router}
appName={APPS.AUTH}
/>
);
return <TwoFactorSetupPage appContext={appContext} appName={APPS.AUTH} />;
}

View file

@ -1,17 +1,9 @@
import TwoFactorVerifyPage from "@ente/accounts/pages/two-factor/verify";
import { APPS } from "@ente/shared/apps/constants";
import { useRouter } from "next/router";
import { AppContext } from "pages/_app";
import { AppContext } from "../../_app";
import { useContext } from "react";
export default function TwoFactorVerify() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<TwoFactorVerifyPage
appContext={appContext}
router={router}
appName={APPS.AUTH}
/>
);
return <TwoFactorVerifyPage appContext={appContext} appName={APPS.AUTH} />;
}

View file

@ -7,11 +7,5 @@ import { useContext } from "react";
export default function Verify() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<VerifyPage
appContext={appContext}
router={router}
appName={APPS.AUTH}
/>
);
return <VerifyPage appContext={appContext} appName={APPS.AUTH} />;
}

View file

@ -7,11 +7,5 @@ import { useContext } from "react";
export default function NotFound() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<NotFoundPage
appContext={appContext}
router={router}
appName={APPS.AUTH}
/>
);
return <NotFoundPage appContext={appContext} appName={APPS.AUTH} />;
}

View file

@ -7,11 +7,5 @@ import { useContext } from "react";
export default function ChangeEmail() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<ChangeEmailPage
appContext={appContext}
router={router}
appName={APPS.PHOTOS}
/>
);
return <ChangeEmailPage appContext={appContext} appName={APPS.PHOTOS} />;
}

View file

@ -1,17 +1,9 @@
import ChangePasswordPage from "@ente/accounts/pages/change-password";
import { APPS } from "@ente/shared/apps/constants";
import { useRouter } from "next/router";
import { AppContext } from "pages/_app";
import { useContext } from "react";
export default function ChangePassword() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<ChangePasswordPage
appContext={appContext}
router={router}
appName={APPS.PHOTOS}
/>
);
return <ChangePasswordPage appContext={appContext} appName={APPS.PHOTOS} />;
}

View file

@ -7,11 +7,5 @@ import { useContext } from "react";
export default function Credential() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<CredentialPage
appContext={appContext}
router={router}
appName={APPS.PHOTOS}
/>
);
return <CredentialPage appContext={appContext} appName={APPS.PHOTOS} />;
}

View file

@ -1,17 +1,9 @@
import GeneratePage from "@ente/accounts/pages/generate";
import { APPS } from "@ente/shared/apps/constants";
import { useRouter } from "next/router";
import { AppContext } from "pages/_app";
import { useContext } from "react";
export default function Generate() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<GeneratePage
appContext={appContext}
router={router}
appName={APPS.PHOTOS}
/>
);
return <GeneratePage appContext={appContext} appName={APPS.PHOTOS} />;
}

View file

@ -1,17 +1,9 @@
import LoginPage from "@ente/accounts/pages/login";
import { APPS } from "@ente/shared/apps/constants";
import { useRouter } from "next/router";
import { AppContext } from "pages/_app";
import { useContext } from "react";
export default function Login() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<LoginPage
appContext={appContext}
router={router}
appName={APPS.PHOTOS}
/>
);
return <LoginPage appContext={appContext} appName={APPS.PHOTOS} />;
}

View file

@ -7,11 +7,5 @@ import { useContext } from "react";
export default function Recover() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<RecoverPage
appContext={appContext}
router={router}
appName={APPS.PHOTOS}
/>
);
return <RecoverPage appContext={appContext} appName={APPS.PHOTOS} />;
}

View file

@ -7,11 +7,5 @@ import { useContext } from "react";
export default function Sigup() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<SignupPage
appContext={appContext}
router={router}
appName={APPS.PHOTOS}
/>
);
return <SignupPage appContext={appContext} appName={APPS.PHOTOS} />;
}

View file

@ -1,17 +1,11 @@
import TwoFactorRecoverPage from "@ente/accounts/pages/two-factor/recover";
import { APPS } from "@ente/shared/apps/constants";
import { useRouter } from "next/router";
import { AppContext } from "pages/_app";
import { useContext } from "react";
export default function TwoFactorRecover() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<TwoFactorRecoverPage
appContext={appContext}
router={router}
appName={APPS.PHOTOS}
/>
<TwoFactorRecoverPage appContext={appContext} appName={APPS.PHOTOS} />
);
}

View file

@ -7,11 +7,5 @@ import { useContext } from "react";
export default function TwoFactorSetup() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<TwoFactorSetupPage
appContext={appContext}
router={router}
appName={APPS.PHOTOS}
/>
);
return <TwoFactorSetupPage appContext={appContext} appName={APPS.PHOTOS} />;
}

View file

@ -1,17 +1,11 @@
import TwoFactorVerifyPage from "@ente/accounts/pages/two-factor/verify";
import { APPS } from "@ente/shared/apps/constants";
import { useRouter } from "next/router";
import { AppContext } from "pages/_app";
import { useContext } from "react";
export default function TwoFactorVerify() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<TwoFactorVerifyPage
appContext={appContext}
router={router}
appName={APPS.PHOTOS}
/>
<TwoFactorVerifyPage appContext={appContext} appName={APPS.PHOTOS} />
);
}

View file

@ -1,17 +1,9 @@
import VerifyPage from "@ente/accounts/pages/verify";
import { APPS } from "@ente/shared/apps/constants";
import { useRouter } from "next/router";
import { AppContext } from "pages/_app";
import { useContext } from "react";
export default function Verify() {
const appContext = useContext(AppContext);
const router = useRouter();
return (
<VerifyPage
appContext={appContext}
router={router}
appName={APPS.PHOTOS}
/>
);
return <VerifyPage appContext={appContext} appName={APPS.PHOTOS} />;
}

View file

@ -1,6 +1,7 @@
import { logError } from "@ente/shared/sentry";
import { LS_KEYS, getData } from "@ente/shared/storage/localStorage";
import { User } from "@ente/shared/user/types";
import { downloadUsingAnchor } from "@ente/shared/utils";
import {
FILE_TYPE,
RAW_FORMATS,

View file

@ -23,11 +23,7 @@ function ChangeEmailPage({ appName, appContext }: PageProps) {
<VerticallyCentered>
<FormPaper>
<FormPaperTitle>{t("CHANGE_EMAIL")}</FormPaperTitle>
<ChangeEmailForm
router={router}
appName={appName}
appContext={appContext}
/>
<ChangeEmailForm appName={appName} appContext={appContext} />
</FormPaper>
</VerticallyCentered>
);

View file

@ -23,6 +23,7 @@ import { ApiError } from "@ente/shared/error";
import { Link } from "@mui/material";
import { HttpStatusCode } from "axios";
import { t } from "i18next";
import { useRouter } from "next/router";
import { Trans } from "react-i18next";
const bip39 = require("bip39");
@ -30,7 +31,6 @@ const bip39 = require("bip39");
bip39.setDefaultWordlist("english");
export default function Recover({
router,
appContext,
twoFactorType = TwoFactorType.TOTP,
}: PageProps) {
@ -40,6 +40,8 @@ export default function Recover({
const [doesHaveEncryptedRecoveryKey, setDoesHaveEncryptedRecoveryKey] =
useState(false);
const router = useRouter();
useEffect(() => {
const user = getData(LS_KEYS.USER);
if (!user || !user.email || !user.twoFactorSessionID) {

View file

@ -1,7 +1,4 @@
import { enableTwoFactor, setupTwoFactor } from "@ente/accounts/api/user";
import { t } from "i18next";
import { useEffect, useState } from "react";
import VerifyTwoFactor, {
VerifyTwoFactorCallback,
} from "@ente/accounts/components/two-factor/VerifyForm";
@ -16,16 +13,21 @@ import { logError } from "@ente/shared/sentry";
import { LS_KEYS, getData, setData } from "@ente/shared/storage/localStorage";
import { Box, CardContent, Typography } from "@mui/material";
import Card from "@mui/material/Card";
import { t } from "i18next";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
export enum SetupMode {
QR_CODE,
MANUAL_CODE,
}
export default function SetupTwoFactor({ router, appName }: PageProps) {
export default function SetupTwoFactor({ appName }: PageProps) {
const [twoFactorSecret, setTwoFactorSecret] =
useState<TwoFactorSecret>(null);
const router = useRouter();
useEffect(() => {
if (twoFactorSecret) {
return;

View file

@ -4,12 +4,7 @@ import VerifyTwoFactor, {
} from "@ente/accounts/components/two-factor/VerifyForm";
import { PAGES } from "@ente/accounts/constants/pages";
import { logoutUser } from "@ente/accounts/services/user";
import { LS_KEYS, getData, setData } from "@ente/shared/storage/localStorage";
import { User } from "@ente/shared/user/types";
import { t } from "i18next";
import { useEffect, useState } from "react";
import { PageProps } from "@ente/shared/apps/types";
import type { PageProps } from "@ente/shared/apps/types";
import { VerticallyCentered } from "@ente/shared/components/Container";
import FormPaper from "@ente/shared/components/Form/FormPaper";
import FormPaperFooter from "@ente/shared/components/Form/FormPaper/Footer";
@ -17,11 +12,18 @@ import FormTitle from "@ente/shared/components/Form/FormPaper/Title";
import LinkButton from "@ente/shared/components/LinkButton";
import { ApiError } from "@ente/shared/error";
import InMemoryStore, { MS_KEYS } from "@ente/shared/storage/InMemoryStore";
import { LS_KEYS, getData, setData } from "@ente/shared/storage/localStorage";
import { User } from "@ente/shared/user/types";
import { HttpStatusCode } from "axios";
import { t } from "i18next";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
export default function TwoFactorVerify({ router }: PageProps) {
export const TwoFactorVerify: React.FC<PageProps> = () => {
const [sessionID, setSessionID] = useState("");
const router = useRouter();
useEffect(() => {
const main = async () => {
const user: User = getData(LS_KEYS.USER);
@ -84,4 +86,6 @@ export default function TwoFactorVerify({ router }: PageProps) {
</FormPaper>
</VerticallyCentered>
);
}
};
export default TwoFactorVerify;

View file

@ -26,16 +26,19 @@ import { clearKeys } from "@ente/shared/storage/sessionStorage";
import { KeyAttributes, User } from "@ente/shared/user/types";
import { Box, Typography } from "@mui/material";
import { HttpStatusCode } from "axios";
import { useRouter } from "next/router";
import { putAttributes, sendOtt, verifyOtt } from "../api/user";
import { PAGES } from "../constants/pages";
import { configureSRP } from "../services/srp";
import { logoutUser } from "../services/user";
import { SRPSetupAttributes } from "../types/srp";
export default function VerifyPage({ appContext, router, appName }: PageProps) {
export default function VerifyPage({ appContext, appName }: PageProps) {
const [email, setEmail] = useState("");
const [resend, setResend] = useState(0);
const router = useRouter();
useEffect(() => {
const main = async () => {
const user: User = getData(LS_KEYS.USER);

View file

@ -29,8 +29,9 @@ export function isPromise<T>(obj: T | Promise<T>): obj is Promise<T> {
export async function retryAsyncFunction<T>(
request: (abort?: () => void) => Promise<T>,
waitTimeBeforeNextTry?: number[],
): Promise<T> {
const waitTimeBeforeNextTry = [2000, 5000, 10000];
if (!waitTimeBeforeNextTry) waitTimeBeforeNextTry = [2000, 5000, 10000];
for (
let attemptNumber = 0;