Skip to content

armgit / ente

Public Imported from GitHub
0

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

Refine Space friend request validation and toast dismissal

Anand Baburajan92248a431cfc
diff --git a/web/apps/space/src/components/AddFriendDialog.tsx b/web/apps/space/src/components/AddFriendDialog.tsx
index 72d9a88649..406e6629df 100644
--- a/web/apps/space/src/components/AddFriendDialog.tsx
+++ b/web/apps/space/src/components/AddFriendDialog.tsx
@@ -58,6 +58,7 @@ export const SpaceAddFriendDialog: React.FC<SpaceAddFriendDialogProps> = ({
const [errorMessage, setErrorMessage] = React.useState<string>();
const [isSharing, setIsSharing] = React.useState(false);
const [shareErrorMessage, setShareErrorMessage] = React.useState<string>();
+ const hasError = errorMessage !== undefined;
const submit = () => {
if (isSubmitting || isSent) return;
@@ -65,8 +66,8 @@ export const SpaceAddFriendDialog: React.FC<SpaceAddFriendDialogProps> = ({
const normalizedUsername = normalizeSpaceUsername(username);
const validationError = normalizedUsername
? spaceUsernameValidationError(normalizedUsername)
- : "Enter a username.";
- if (validationError) {
+ : "";
+ if (validationError !== undefined) {
setErrorMessage(validationError);
return;
}
@@ -224,15 +225,15 @@ export const SpaceAddFriendDialog: React.FC<SpaceAddFriendDialogProps> = ({
sx={{
alignItems: "center",
bgcolor: spaceSurface,
- border: `1px solid ${errorMessage ? dangerColor : "transparent"}`,
+ border: `1px solid ${hasError ? dangerColor : "transparent"}`,
borderRadius: "14px",
display: "flex",
height: 48,
px: "14px",
width: "100%",
"&:focus-within": {
- borderColor: green,
- boxShadow: `0 0 0 1px ${green}`,
+ borderColor: hasError ? dangerColor : green,
+ boxShadow: `0 0 0 1px ${hasError ? dangerColor : green}`,
},
}}
>
@@ -257,7 +258,7 @@ export const SpaceAddFriendDialog: React.FC<SpaceAddFriendDialogProps> = ({
autoCorrect="off"
autoFocus
aria-label="Friend's username"
- aria-invalid={Boolean(errorMessage) || undefined}
+ aria-invalid={hasError || undefined}
disabled={isSubmitting || isSent}
onChange={(
event: React.ChangeEvent<HTMLInputElement>,
diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsx
index 83c03b6e14..8ebe716a78 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -2,10 +2,7 @@ import { Cancel01Icon, UserAdd02Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import { Box } from "@mui/material";
import { SpaceActionFeedbackIcon } from "components/ActionFeedback";
-import {
- SpaceActionToast,
- spaceToastAutoDismissDurationMs,
-} from "components/ActionToast";
+import { SpaceActionToast } from "components/ActionToast";
import { SpaceAddFriendButton } from "components/AddFriendButton";
import { SpaceAddFriendTile } from "components/AddFriendTile";
import { SpaceAvatarImage } from "components/AvatarImage";
@@ -989,7 +986,6 @@ const AddedFriendToast: React.FC<AddedFriendToastProps> = ({
onClose,
}) => (
<SpaceActionToast
- autoDismissAfterMs={spaceToastAutoDismissDurationMs}
closeLabel="Dismiss friend request status"
icon={
<HugeiconsIcon icon={UserAdd02Icon} size={20} strokeWidth={1.8} />