π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Another helper
Manav Rathi68e7a38463a0
diff --git a/web/apps/accounts/src/pages/_app.tsx b/web/apps/accounts/src/pages/_app.tsxindex 87a1008602..36bbcd39ab 100644--- a/web/apps/accounts/src/pages/_app.tsx+++ b/web/apps/accounts/src/pages/_app.tsx@@ -1,9 +1,9 @@import { staticAppTitle } from "@/base/app";import { CustomHead } from "@/base/components/Head";-import { useAttributedMiniDialog } from "@/base/components/hooks/use-mini-dialog";import { AttributedMiniDialog } from "@/base/components/MiniDialog";import { ActivityIndicator } from "@/base/components/mui/ActivityIndicator";import { AppNavbar } from "@/base/components/Navbar";+import { useAttributedMiniDialog } from "@/base/hooks/use-mini-dialog";import { setupI18n } from "@/base/i18n";import { disableDiskLogs } from "@/base/log";import { logUnhandledErrorsAndRejections } from "@/base/log-web";diff --git a/web/apps/accounts/src/pages/passkeys/index.tsx b/web/apps/accounts/src/pages/passkeys/index.tsxindex d365af0b6d..c909602910 100644--- a/web/apps/accounts/src/pages/passkeys/index.tsx+++ b/web/apps/accounts/src/pages/passkeys/index.tsx@@ -34,7 +34,7 @@ import {import { useAppContext } from "../../types/context";const Page: React.FC = () => {- const { showNavBar, setDialogBoxAttributesV2 } = useAppContext();+ const { showNavBar, showMiniDialog } = useAppContext();const [token, setToken] = useState<string | undefined>();const [passkeys, setPasskeys] = useState<Passkey[]>([]);@@ -44,12 +44,12 @@ const Page: React.FC = () => {>();const showPasskeyFetchFailedErrorDialog = useCallback(() => {- setDialogBoxAttributesV2({+ showMiniDialog({title: t("error"),message: t("passkey_fetch_failed"),- close: {},+ cancel: false,});- }, [setDialogBoxAttributesV2]);+ }, [showMiniDialog]);useEffect(() => {showNavBar(true);diff --git a/web/packages/base/components/hooks/use-mini-dialog.ts b/web/packages/base/components/utils/use-mini-dialog.tsxsimilarity index 55%rename from web/packages/base/components/hooks/use-mini-dialog.tsrename to web/packages/base/components/utils/use-mini-dialog.tsxindex 8ac74536a0..cad7a557f2 100644--- a/web/packages/base/components/hooks/use-mini-dialog.ts+++ b/web/packages/base/components/utils/use-mini-dialog.tsx@@ -1,3 +1,5 @@+import ErrorOutline from "@mui/icons-material/ErrorOutline";+import { t } from "i18next";import { useCallback, useState } from "react";import type { MiniDialogAttributes } from "../MiniDialog";@@ -29,3 +31,29 @@ export const useAttributedMiniDialog = () => {},};};++/**+ * A convenience function to construct {@link MiniDialogAttributes} for showing+ * error dialogs.+ *+ * It takes one or two arguments.+ *+ * - If both are provided, then the first one is taken as the title and the+ * second one as the message.+ *+ * - Otherwise it sets a default title and use the only argument as the message.+ */+export const errorAttributes = (+ messageOrTitle: string,+ optionalMessage?: string,+): MiniDialogAttributes => {+ const title = optionalMessage ? messageOrTitle : t("error");+ const message = optionalMessage ? optionalMessage : messageOrTitle;++ return {+ title,+ icon: <ErrorOutline />,+ message,+ continue: { color: "critical" },+ };+};diff --git a/web/packages/build-config/eslintrc-react.js b/web/packages/build-config/eslintrc-react.jsindex 571d37e622..098403b08b 100644--- a/web/packages/build-config/eslintrc-react.js+++ b/web/packages/build-config/eslintrc-react.js@@ -13,9 +13,14 @@ module.exports = {"react/jsx-no-target-blank": ["warn", { allowReferrer: true }],/* Otherwise we need to do unnecessary boilerplating when using memo. */"react/display-name": "off",+ /* Apparently Fast refresh only works if a file only exports components,+ and this rule warns about that. Constants are okay though (otherwise+ we'll need to create unnecessary helper files). */"react-refresh/only-export-components": ["warn",{ allowConstantExport: true },],+ /* Next.js supports the JSX transform introduced in React 17 */+ "react/react-in-jsx-scope": "off",},};