Skip to content

armgit / ente

Public Imported from GitHub
0

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

Fin

Manav Rathi4891f470b160
diff --git a/web/apps/auth/eslint.config.mjs b/web/apps/auth/eslint.config.mjs
index 24a9bd9277..06dd5eefb9 100644
--- a/web/apps/auth/eslint.config.mjs
+++ b/web/apps/auth/eslint.config.mjs
@@ -1,12 +1 @@
-import config from "@/build-config/eslintrc-next-app.mjs";
-
-export default [
- ...config,
- {
- rules: {
- // We want to turn this off globally, but after having revisited all
- // existing uses.
- "@typescript-eslint/prefer-nullish-coalescing": "off",
- },
- },
-];
+export { default } from "@/build-config/eslintrc-next-app.mjs";
diff --git a/web/apps/auth/src/pages/auth.tsx b/web/apps/auth/src/pages/auth.tsx
index 320ad15a17..33f097eda7 100644
--- a/web/apps/auth/src/pages/auth.tsx
+++ b/web/apps/auth/src/pages/auth.tsx
@@ -25,7 +25,7 @@ import {
} from "@mui/material";
import { t } from "i18next";
import { useRouter } from "next/router";
-import React, { useEffect, useState } from "react";
+import React, { useCallback, useEffect, useState } from "react";
import { generateOTPs, type Code } from "services/code";
import { getAuthCodes } from "services/remote";
import { useAppContext } from "types/context";
@@ -180,7 +180,7 @@ const CodeDisplay: React.FC<CodeDisplayProps> = ({ code }) => {
const [errorMessage, setErrorMessage] = useState("");
const [hasCopied, setHasCopied] = useState(false);
- const regen = () => {
+ const regen = useCallback(() => {
try {
const [m, n] = generateOTPs(code);
setOTP(m);
@@ -188,7 +188,7 @@ const CodeDisplay: React.FC<CodeDisplayProps> = ({ code }) => {
} catch (e) {
setErrorMessage(e instanceof Error ? e.message : String(e));
}
- };
+ }, [code]);
const copyCode = () =>
void navigator.clipboard.writeText(otp).then(() => {
@@ -214,7 +214,7 @@ const CodeDisplay: React.FC<CodeDisplayProps> = ({ code }) => {
}, timeToNextCode);
return () => interval && clearInterval(interval);
- }, [code]);
+ }, [code, regen]);
return (
<div style={{ padding: "8px" }}>
diff --git a/web/apps/auth/src/services/code.ts b/web/apps/auth/src/services/code.ts
index a7b1662b5d..768a1a7428 100644
--- a/web/apps/auth/src/services/code.ts
+++ b/web/apps/auth/src/services/code.ts
@@ -234,7 +234,7 @@ export const generateOTPs = (code: Code): [otp: string, nextOTP: string] => {
}
case "hotp": {
- const counter = code.counter || 0;
+ const counter = code.counter ?? 0;
const hotp = new HOTP({
secret: code.secret,
counter: counter,