This commit is contained in:
Manav Rathi 2024-10-10 15:22:21 +05:30
parent 03e5e16bc3
commit 6b64e20a7e
No known key found for this signature in database
3 changed files with 11 additions and 17 deletions

View File

@ -1,7 +1,7 @@
import { EnteDrawer } from "@/base/components/EnteDrawer";
import { MenuItemDivider, MenuItemGroup } from "@/base/components/Menu";
import { Titlebar } from "@/base/components/Titlebar";
import { mdErrorAttributes } from "@/base/components/utils/mini-dialog";
import { errorDialogAttributes } from "@/base/components/utils/mini-dialog";
import log from "@/base/log";
import { ensure } from "@/utils/ensure";
import { CenteredFlex } from "@ente/shared/components/Container";
@ -45,7 +45,7 @@ const Page: React.FC = () => {
>();
const showPasskeyFetchFailedErrorDialog = useCallback(() => {
showMiniDialog(mdErrorAttributes(t("passkey_fetch_failed")));
showMiniDialog(errorDialogAttributes(t("passkey_fetch_failed")));
}, [showMiniDialog]);
useEffect(() => {

View File

@ -5,6 +5,7 @@ import {
} from "@/accounts/services/passkey";
import type { MiniDialogAttributes } from "@/base/components/MiniDialog";
import { FocusVisibleButton } from "@/base/components/mui/FocusVisibleButton";
import { genericErrorDialogAttributes } from "@/base/components/utils/mini-dialog";
import log from "@/base/log";
import { customAPIHost } from "@/base/origins";
import { VerticallyCentered } from "@ente/shared/components/Container";
@ -108,7 +109,7 @@ export const VerifyingPasskey: React.FC<VerifyingPasskeyProps> = ({
e instanceof Error &&
e.message == passkeySessionExpiredErrorMessage
? sessionExpiredDialogAttributes(logout)
: genericErrorAttributes(),
: genericErrorDialogAttributes(),
);
setVerificationStatus("waiting");
}
@ -194,11 +195,10 @@ const ButtonStack = styled("div")`
`;
/**
* {@link DialogBoxAttributesV2} for showing the error when the user's session
* has expired.
* {@link MiniDialogAttributes} for showing asking the user to login again when
* their session has expired.
*
* It asks them to login again. There is one button, which allows them to
* logout.
* There is one button, which allows them to logout.
*
* @param onLogin Called when the user presses the "Login" button on the error
* dialog.
@ -215,12 +215,3 @@ export const sessionExpiredDialogAttributes = (
},
cancel: false,
});
/**
* {@link DialogBoxAttributesV2} for showing a generic error.
*/
const genericErrorAttributes = (): MiniDialogAttributes => ({
title: t("error"),
close: { variant: "critical" },
message: t("generic_error_retry"),
});

View File

@ -43,7 +43,7 @@ export const useAttributedMiniDialog = () => {
*
* - Otherwise it sets a default title and use the only argument as the message.
*/
export const mdErrorAttributes = (
export const errorDialogAttributes = (
messageOrTitle: string,
optionalMessage?: string,
): MiniDialogAttributes => {
@ -57,3 +57,6 @@ export const mdErrorAttributes = (
continue: { color: "critical" },
};
};
export const genericErrorDialogAttributes = () =>
errorDialogAttributes(t("generic_error"));