Skip to content

armgit / ente

Public Imported from GitHub
0

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

Polish Space invite and messages

Anand Baburajana8ad30d0ae8a
diff --git a/web/apps/space/src/components/SpaceInviteFriendsDialog.tsx b/web/apps/space/src/components/SpaceInviteFriendsDialog.tsx
deleted file mode 100644
index a43eb4068d..0000000000
--- a/web/apps/space/src/components/SpaceInviteFriendsDialog.tsx
+++ /dev/null
@@ -1,179 +0,0 @@
-import { Share08Icon } from "@hugeicons/core-free-icons";
-import { HugeiconsIcon } from "@hugeicons/react";
-import { Box, Dialog, useMediaQuery } from "@mui/material";
-import { SpaceBottomSheetTransition } from "components/SpaceBottomSheetTransition";
-import React from "react";
-
-const textBase = "#000";
-const textSoft = "#777777";
-const dangerColor = "#F63A3A";
-
-interface SpaceInviteFriendsDialogProps {
- errorMessage?: string | null;
- open: boolean;
- sharing: boolean;
- onClose: () => void;
- onShare: () => void;
-}
-
-export const SpaceInviteFriendsDialog: React.FC<
- SpaceInviteFriendsDialogProps
-> = ({ errorMessage, open, sharing, onClose, onShare }) => {
- const titleID = React.useId();
- const isBottomSheet = useMediaQuery("(max-width: 599px)");
-
- return (
- <Dialog
- open={open}
- onClose={sharing ? undefined : onClose}
- maxWidth={false}
- aria-labelledby={titleID}
- slots={
- isBottomSheet
- ? { transition: SpaceBottomSheetTransition }
- : undefined
- }
- slotProps={{
- backdrop: { sx: { backgroundColor: "rgba(0, 0, 0, 0.48)" } },
- paper: {
- sx: {
- bgcolor: "#FAFAFA",
- borderRadius: "28px 28px 0 0",
- bottom: 0,
- boxShadow: "none",
- boxSizing: "border-box",
- left: 0,
- m: 0,
- maxWidth: "none",
- p: "26px 20px calc(24px + env(safe-area-inset-bottom))",
- position: "fixed",
- width: "100vw",
- "@media (min-width: 600px)": {
- borderRadius: "20px",
- bottom: "auto",
- boxShadow: "0 18px 48px rgba(0, 0, 0, 0.18)",
- left: "50%",
- maxWidth: 342,
- p: "24px 20px 20px",
- top: "50%",
- transform: "translate(-50%, -50%)",
- width: 342,
- },
- },
- },
- }}
- >
- <Box
- sx={{
- maxWidth: 320,
- mx: "auto",
- width: "100%",
- "@media (min-width: 600px)": { maxWidth: "none" },
- }}
- >
- <Box
- component="h2"
- id={titleID}
- sx={{
- color: textBase,
- fontFamily: '"Inter Variable", Inter, sans-serif',
- fontSize: 15,
- fontWeight: 600,
- lineHeight: "20px",
- m: 0,
- px: "20px",
- textAlign: "center",
- }}
- >
- Invite friends
- </Box>
- <Box
- component="p"
- sx={{
- color: textSoft,
- fontFamily: '"Inter Variable", Inter, sans-serif',
- fontSize: 14,
- fontWeight: 500,
- lineHeight: "20px",
- m: 0,
- mt: "10px",
- textAlign: "center",
- }}
- >
- Invite friends and family by sharing your private profile
- link. Only you and the people you share it with can see your
- posts.
- </Box>
- <Box
- sx={{
- display: "flex",
- flexDirection: "column",
- gap: "10px",
- mt: "22px",
- }}
- >
- <Box
- className="green-bg"
- component="button"
- type="button"
- disabled={sharing}
- onClick={onShare}
- sx={{
- alignItems: "center",
- border: 0,
- borderRadius: "20px",
- color: "#FFFFFF",
- cursor: sharing ? "default" : "pointer",
- display: "flex",
- gap: "10px",
- fontFamily: '"Inter Variable", Inter, sans-serif',
- fontSize: 14,
- fontWeight: 600,
- justifyContent: "center",
- lineHeight: "20px",
- height: 48,
- px: "24px",
- py: "14px",
- transition: "filter 120ms ease, opacity 120ms ease",
- width: "100%",
- "&:active": sharing
- ? undefined
- : { filter: "brightness(0.96)" },
- "&:disabled": { opacity: 1 },
- "&:focus-visible": {
- outline: "2px solid rgba(0 0 0 / 0.72)",
- outlineOffset: 2,
- },
- "&:hover": sharing
- ? undefined
- : { filter: "brightness(0.98)" },
- }}
- >
- <HugeiconsIcon
- icon={Share08Icon}
- size={18}
- strokeWidth={1.8}
- />
- {sharing ? "Sharing..." : "Share invite"}
- </Box>
- {errorMessage && (
- <Box
- role="alert"
- sx={{
- color: dangerColor,
- fontFamily:
- '"Inter Variable", Inter, sans-serif',
- fontSize: 13,
- fontWeight: 650,
- lineHeight: "18px",
- textAlign: "center",
- }}
- >
- {errorMessage}
- </Box>
- )}
- </Box>
- </Box>
- </Dialog>
- );
-};
diff --git a/web/apps/space/src/pages/app/index.tsx b/web/apps/space/src/pages/app/index.tsx
index 951745beaa..2adb7a54b1 100644
--- a/web/apps/space/src/pages/app/index.tsx
+++ b/web/apps/space/src/pages/app/index.tsx
@@ -22,7 +22,6 @@ import {
createLocalFeedPostID,
failLocalFeedPost,
} from "utils/localFeedPost";
-import { firstNameFrom } from "utils/spaceDisplay";
import { prepareSpacePostImageFromEdit } from "utils/spacePostImage";
import { spaceRoutes } from "utils/spaceRoutes";
import { useSpaceRouter } from "utils/spaceRouteTransitions";
@@ -75,11 +74,7 @@ const Page: React.FC = () => {
const sentFriend = consumeSentSpaceInviteFriend();
if (!sentFriend) return;
- const displayName =
- sentFriend.fullName.trim() || sentFriend.username.trim();
- setFriendRequestSentToastName(
- firstNameFrom(displayName) || displayName,
- );
+ setFriendRequestSentToastName(sentFriend.username.trim());
}, [router.isReady]);
useEffect(() => {
diff --git a/web/apps/space/src/pages/index.tsx b/web/apps/space/src/pages/index.tsx
index 893824b3f1..73aed73522 100644
--- a/web/apps/space/src/pages/index.tsx
+++ b/web/apps/space/src/pages/index.tsx
@@ -1,3 +1,5 @@
+import { UserAdd02Icon } from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
import { Box } from "@mui/material";
import { SpacePageMeta } from "components/SpacePageMeta";
import { SpaceRouteFallback } from "components/SpaceRouteFallback";
@@ -66,20 +68,6 @@ const PublicProfileUnavailable: React.FC = () => (
>
Profile unavailable
</Box>
- <Box
- component="p"
- sx={{
- color: "#AAFFB8",
- fontFamily: '"Inter Variable", Inter, sans-serif',
- fontSize: 14,
- fontWeight: 500,
- lineHeight: "20px",
- m: 0,
- mt: "6px",
- }}
- >
- This profile is unavailable.
- </Box>
</Box>
</Box>
);
@@ -97,120 +85,155 @@ const PublicFriendRequestScreen: React.FC<PublicFriendRequestScreenProps> = ({
onAddFriend,
}) => (
<Box
- className="green-bg"
component="main"
sx={{
- alignItems: "center",
- bgcolor: onboardingGreen,
+ bgcolor: "white",
boxSizing: "border-box",
- color: "white",
- display: "flex",
- flexDirection: "column",
+ display: "grid",
minHeight: "100svh",
- px: 3,
- textAlign: "center",
+ p: { xs: 1, sm: 0 },
+ placeItems: "stretch",
}}
>
<Box
- component="header"
- sx={{
- alignItems: "center",
- display: "grid",
- flexShrink: 0,
- gridTemplateColumns: "40px 1fr 40px",
- height: 40,
- mt: "clamp(24px, 5.5svh, 44px)",
- width: "100%",
- "@media (min-width: 600px)": { maxWidth: 390 },
- }}
- >
- <Box />
- <Box
- component="img"
- alt="Ente Space"
- src="/images/space.svg"
- sx={{
- display: "block",
- height: 30,
- justifySelf: "center",
- width: 101,
- }}
- />
- <Box />
- </Box>
- <Box
+ className="green-bg"
sx={{
alignItems: "center",
+ bgcolor: onboardingGreen,
+ borderRadius: { xs: "24px", sm: 0 },
+ boxSizing: "border-box",
+ color: "white",
display: "flex",
- flex: "1 1 auto",
flexDirection: "column",
- justifyContent: "center",
- maxWidth: 390,
- pb: "calc(env(safe-area-inset-bottom) + 48px)",
+ minHeight: { xs: "calc(100svh - 16px)", sm: "100svh" },
+ overflow: "hidden",
+ textAlign: "center",
width: "100%",
}}
>
<Box
- component="h1"
+ component="header"
sx={{
- fontFamily: "Nunito, sans-serif",
- fontSize: 32,
- fontWeight: 800,
- letterSpacing: 0,
- lineHeight: "38px",
- m: 0,
- maxWidth: "100%",
- overflowWrap: "anywhere",
+ alignItems: "center",
+ display: "grid",
+ flexShrink: 0,
+ gridTemplateColumns: "40px 1fr 40px",
+ height: 40,
+ maxWidth: 390,
+ mt: "clamp(24px, 5.5svh, 44px)",
+ mx: "auto",
+ px: 3,
+ width: "100%",
}}
>
- @{identity.username}
+ <Box />
+ <Box
+ component="img"
+ alt="Ente Space"
+ src="/images/space.svg"
+ sx={{
+ display: "block",
+ height: 30,
+ justifySelf: "center",
+ width: 101,
+ }}
+ />
+ <Box />
</Box>
<Box
- component="p"
sx={{
- color: "#AAFFB8",
- fontFamily: '"Inter Variable", Inter, sans-serif',
- fontSize: 15,
- fontWeight: 600,
- lineHeight: "22px",
- m: 0,
- mt: "10px",
- maxWidth: 300,
+ alignItems: "center",
+ display: "flex",
+ flex: "1 1 auto",
+ flexDirection: "column",
+ justifyContent: "center",
+ maxWidth: 390,
+ minHeight: 0,
+ px: 3,
+ width: "100%",
}}
>
- Send a request to add @{identity.username} as a friend on Ente
- Space.
+ <Box
+ component="h1"
+ sx={{
+ fontFamily: "Nunito, sans-serif",
+ fontSize: 28,
+ fontWeight: 800,
+ letterSpacing: 0,
+ lineHeight: "34px",
+ m: 0,
+ maxWidth: "100%",
+ overflowWrap: "anywhere",
+ }}
+ >
+ @{identity.username} invited you!
+ </Box>
+ <Box
+ component="p"
+ sx={{
+ color: "#AAFFB8",
+ fontFamily: '"Inter Variable", Inter, sans-serif',
+ fontSize: 15,
+ fontWeight: 600,
+ lineHeight: "22px",
+ m: 0,
+ mt: "10px",
+ maxWidth: 300,
+ }}
+ >
+ See what @{identity.username} is up to
+ <br />
+ on Ente Space.
+ </Box>
</Box>
<Box
- component="button"
- type="button"
- onClick={onAddFriend}
sx={{
- alignItems: "center",
- appearance: "none",
- bgcolor: "black",
- border: 0,
- borderRadius: "20px",
- color: "white",
- cursor: "pointer",
- display: "flex",
- fontFamily: '"Inter Variable", Inter, sans-serif',
- fontSize: 16,
- fontWeight: 650,
- height: 52,
- justifyContent: "center",
- lineHeight: "20px",
- mt: "28px",
- px: 4,
+ boxSizing: "border-box",
+ flexShrink: 0,
+ maxWidth: 390,
+ mx: "auto",
+ pb: "calc(env(safe-area-inset-bottom) + 24px)",
+ px: 3,
+ pt: 3,
width: "100%",
- "&:hover": { bgcolor: "#121212" },
- "&:focus-visible": {
- outline: "2px solid rgba(255 255 255 / 0.88)",
- outlineOffset: 3,
- },
}}
>
- Add friend
+ <Box
+ component="button"
+ type="button"
+ onClick={onAddFriend}
+ sx={{
+ alignItems: "center",
+ appearance: "none",
+ bgcolor: "black",
+ border: 0,
+ borderRadius: "20px",
+ color: "white",
+ cursor: "pointer",
+ display: "flex",
+ gap: "8px",
+ fontFamily: '"Inter Variable", Inter, sans-serif',
+ fontSize: 14,
+ fontWeight: 500,
+ height: 48,
+ justifyContent: "center",
+ lineHeight: "20px",
+ p: "14px 24px",
+ width: "100%",
+ "&:hover": { bgcolor: "#121212" },
+ "&:focus-visible": {
+ outline: "2px solid rgba(255 255 255 / 0.88)",
+ outlineOffset: 3,
+ },
+ }}
+ >
+ <HugeiconsIcon
+ icon={UserAdd02Icon}
+ size={18}
+ strokeWidth={1.8}
+ />
+ Add friend
+ </Box>
</Box>
</Box>
</Box>
@@ -252,8 +275,7 @@ const Page: React.FC = () => {
.then((identity) => {
if (!cancelled) setPublicIdentity(identity);
})
- .catch((error: unknown) => {
- console.error("Failed to load public space identity", error);
+ .catch(() => {
if (!cancelled) setPublicError("This profile is unavailable.");
});
diff --git a/web/apps/space/src/screens/FriendsScreen.tsx b/web/apps/space/src/screens/FriendsScreen.tsx
index 0af070f675..af9806c13c 100644
--- a/web/apps/space/src/screens/FriendsScreen.tsx
+++ b/web/apps/space/src/screens/FriendsScreen.tsx
@@ -12,7 +12,6 @@ import {
type SpaceActionPhase,
} from "components/SpaceActionFeedback";
import { SpaceAvatarImage } from "components/SpaceAvatarImage";
-import { SpaceInviteFriendsDialog } from "components/SpaceInviteFriendsDialog";
import type { FriendProfile } from "data/friends";
import React, { useState } from "react";
import { ShareIcon } from "screens/ShareProfileLinkScreen";
@@ -335,11 +334,7 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({
const [loadedAvatarURLsByKey, setLoadedAvatarURLsByKey] = React.useState<
Record<string, string>
>({});
- const [isInviteDialogOpen, setIsInviteDialogOpen] = React.useState(false);
const [isInviteSharing, setIsInviteSharing] = React.useState(false);
- const [inviteShareError, setInviteShareError] = React.useState<
- string | null
- >(null);
const avatarLoadsInFlightRef = React.useRef<
Map<string, Promise<string | null | undefined>>
>(new Map());
@@ -425,20 +420,9 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({
setUnfriendErrorMessage(null);
};
- const openInviteDialog = () => {
- setInviteShareError(null);
- setIsInviteDialogOpen(true);
- };
-
- const closeInviteDialog = () => {
- if (isInviteSharing) return;
- setIsInviteDialogOpen(false);
- };
-
const shareInviteLink = async () => {
if (!onShareProfileLink || isInviteSharing) return;
setIsInviteSharing(true);
- setInviteShareError(null);
try {
const profileLink = await onShareProfileLink();
@@ -446,7 +430,6 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({
if (typeof navigator.share == "function") {
try {
await navigator.share({ url: profileLink });
- setIsInviteDialogOpen(false);
return;
} catch (error) {
if (
@@ -458,10 +441,8 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({
}
await navigator.clipboard.writeText(profileLink);
- setIsInviteDialogOpen(false);
} catch (error) {
console.error("Failed to share space invite", error);
- setInviteShareError("Couldn't share invite. Please try again.");
} finally {
setIsInviteSharing(false);
}
@@ -549,15 +530,18 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({
<Box
component="button"
type="button"
- aria-label="Invite friends"
- disabled={!onShareProfileLink}
- onClick={openInviteDialog}
+ aria-label="Share invite"
+ disabled={!onShareProfileLink || isInviteSharing}
+ onClick={() => void shareInviteLink()}
sx={{
alignItems: "center",
bgcolor: "transparent",
border: 0,
color: textBase,
- cursor: onShareProfileLink ? "pointer" : "default",
+ cursor:
+ onShareProfileLink && !isInviteSharing
+ ? "pointer"
+ : "default",
display: "flex",
height: spaceTouchTargetSize,
justifyContent: "flex-end",
@@ -629,17 +613,18 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({
<Box
component="button"
type="button"
- disabled={!onShareProfileLink}
- onClick={openInviteDialog}
+ disabled={!onShareProfileLink || isInviteSharing}
+ onClick={() => void shareInviteLink()}
sx={{
alignItems: "center",
bgcolor: "#E8E8E8",
border: 0,
borderRadius: "18px",
color: textBase,
- cursor: onShareProfileLink
- ? "pointer"
- : "default",
+ cursor:
+ onShareProfileLink && !isInviteSharing
+ ? "pointer"
+ : "default",
display: "inline-flex",
fontFamily:
'"Inter Variable", Inter, sans-serif',
@@ -658,13 +643,14 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({
outline: `2px solid ${green}`,
outlineOffset: 2,
},
- "&:hover": onShareProfileLink
+ "&:hover":
+ onShareProfileLink && !isInviteSharing
? { bgcolor: "#DEDEDE" }
: undefined,
}}
>
<ShareIcon />
- Invite friends
+ Share invite
</Box>
</Box>
)}
@@ -681,13 +667,6 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({
onConfirm={confirmUnfriend}
onExited={handleUnfriendSheetExited}
/>
- <SpaceInviteFriendsDialog
- errorMessage={inviteShareError}
- open={isInviteDialogOpen}
- sharing={isInviteSharing}
- onClose={closeInviteDialog}
- onShare={() => void shareInviteLink()}
- />
</Box>
);
};
diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsx
index e52b905ace..a85749a485 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -14,7 +14,6 @@ import {
type SpaceViewerPhoto,
type SpaceViewerPostActionMode,
} from "components/SpaceFileViewer";
-import { SpaceInviteFriendsDialog } from "components/SpaceInviteFriendsDialog";
import { SpacePostFloatingActionButton } from "components/SpacePostFloatingActionButton";
import {
spacePostLikeButtonPop,
@@ -1285,11 +1284,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
}) => {
const [selectedViewer, setSelectedViewer] =
useState<SelectedHomeViewer | null>(null);
- const [isInviteDialogOpen, setIsInviteDialogOpen] = useState(false);
const [isInviteSharing, setIsInviteSharing] = useState(false);
- const [inviteShareError, setInviteShareError] = useState<string | null>(
- null,
- );
const [isPostPhotoOpening, setIsPostPhotoOpening] = useState(false);
const [loadedFeedAvatarURLsByKey, setLoadedFeedAvatarURLsByKey] = useState<
Record<string, string | null>
@@ -1582,27 +1577,15 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
return () => observer.disconnect();
}, [hasMoreFeedItems, isFeedLoadingMore, onLoadMoreFeedItems]);
- const openInviteDialog = () => {
- setInviteShareError(null);
- setIsInviteDialogOpen(true);
- };
-
- const closeInviteDialog = () => {
- if (isInviteSharing) return;
- setIsInviteDialogOpen(false);
- };
-
const shareInviteLink = async () => {
if (!onShareProfileLink || isInviteSharing) return;
setIsInviteSharing(true);
- setInviteShareError(null);
try {
const profileLink = await onShareProfileLink();
if (typeof navigator.share == "function") {
try {
await navigator.share({ url: profileLink });
- setIsInviteDialogOpen(false);
return;
} catch (error) {
if (
@@ -1614,10 +1597,8 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
}
await navigator.clipboard.writeText(profileLink);
- setIsInviteDialogOpen(false);
} catch (error) {
console.error("Failed to share space invite", error);
- setInviteShareError("Couldn't share invite. Please try again.");
} finally {
setIsInviteSharing(false);
}
@@ -2070,14 +2051,21 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
<Box
component="button"
type="button"
- onClick={openInviteDialog}
+ disabled={
+ !onShareProfileLink || isInviteSharing
+ }
+ onClick={() => void shareInviteLink()}
sx={{
alignItems: "center",
bgcolor: "#E8E8E8",
border: 0,
borderRadius: "18px",
color: textBase,
- cursor: "pointer",
+ cursor:
+ onShareProfileLink &&
+ !isInviteSharing
+ ? "pointer"
+ : "default",
display: "inline-flex",
fontFamily:
'"Inter Variable", Inter, sans-serif',
@@ -2090,15 +2078,20 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
mt: emptyFeedItemGap,
px: "14px",
whiteSpace: "nowrap",
+ "&:disabled": { opacity: 0.45 },
"&:focus-visible": {
outline: `2px solid ${green}`,
outlineOffset: 2,
},
- "&:hover": { bgcolor: "#DEDEDE" },
+ "&:hover":
+ onShareProfileLink &&
+ !isInviteSharing
+ ? { bgcolor: "#DEDEDE" }
+ : undefined,
}}
>
<ShareIcon />
- Invite friends
+ Share invite
</Box>
)}
</Box>
@@ -2185,17 +2178,10 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
)}
{friendRequestSentToastName && (
<AddedFriendToast
- message={`Friend request sent to ${friendRequestSentToastName}`}
+ message={`Friend request sent to @${friendRequestSentToastName}`}
onClose={onFriendRequestSentToastClose}
/>
)}
- <SpaceInviteFriendsDialog
- errorMessage={inviteShareError}
- open={isInviteDialogOpen}
- sharing={isInviteSharing}
- onClose={closeInviteDialog}
- onShare={() => void shareInviteLink()}
- />
</Box>
</Box>
);
diff --git a/web/apps/space/src/screens/MessagesScreen.tsx b/web/apps/space/src/screens/MessagesScreen.tsx
index 7c00ca4027..dbabf7fe0b 100644
--- a/web/apps/space/src/screens/MessagesScreen.tsx
+++ b/web/apps/space/src/screens/MessagesScreen.tsx
@@ -14,7 +14,6 @@ import {
Popper,
} from "@mui/material";
import { SpaceAvatarImage } from "components/SpaceAvatarImage";
-import { SpaceInviteFriendsDialog } from "components/SpaceInviteFriendsDialog";
import { SpaceLoadingSpinner } from "components/SpaceRouteFallback";
import { formatTimeAgo } from "ente-base/date";
import React from "react";
@@ -194,7 +193,7 @@ const conversationPreview = (
) => {
const activity = conversation.latestActivity;
if (activity.type == "friend_request") {
- return "Wants to add you as a friend";
+ return "Friend request";
}
if (activity.type == "friend_add") {
return "You're now friends. Say hello!";
@@ -519,7 +518,7 @@ const ConversationListItem: React.FC<{
avatarUrl={conversation.friend.avatarUrl}
size={44}
/>
- {unreadCount > 0 && (
+ {unreadCount > 0 && !isFriendRequest && (
<Box
aria-label={`${unreadCount} unread message${unreadCount == 1 ? "" : "s"}`}
component="span"
@@ -1420,11 +1419,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
const [sendPhase, setSendPhase] = React.useState<"idle" | "sending">(
"idle",
);
- const [isInviteDialogOpen, setIsInviteDialogOpen] = React.useState(false);
const [isInviteSharing, setIsInviteSharing] = React.useState(false);
- const [inviteShareError, setInviteShareError] = React.useState<
- string | null
- >(null);
const composerRef = React.useRef<HTMLTextAreaElement | null>(null);
const threadScrollRef = React.useRef<HTMLDivElement | null>(null);
const stickToThreadBottomRef = React.useRef(true);
@@ -1448,8 +1443,8 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
friendsCount == 0 && Boolean(onShareProfileLink);
const emptyConversationsCopy =
friendsCount == 0
- ? "No messages yet. Once you add friends, you'll see their messages and replies to your posts here."
- : "No messages yet. You'll see your friends' messages and replies to your posts here.";
+ ? "No messages yet. Once you add friends, you'll see their likes, replies and messages here."
+ : "No messages yet. You'll see your friends' likes, replies and messages here.";
const conversationSections = React.useMemo(
() => conversationTimeSections(conversations, newConversationIds),
[conversations, newConversationIds],
@@ -1539,27 +1534,15 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
closeMessageActions();
};
- const openInviteDialog = () => {
- setInviteShareError(null);
- setIsInviteDialogOpen(true);
- };
-
- const closeInviteDialog = () => {
- if (isInviteSharing) return;
- setIsInviteDialogOpen(false);
- };
-
const shareInviteLink = async () => {
if (!onShareProfileLink || isInviteSharing) return;
setIsInviteSharing(true);
- setInviteShareError(null);
try {
const profileLink = await onShareProfileLink();
if (typeof navigator.share == "function") {
try {
await navigator.share({ url: profileLink });
- setIsInviteDialogOpen(false);
return;
} catch (error) {
if (
@@ -1571,10 +1554,8 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
}
await copyTextToClipboard(profileLink);
- setIsInviteDialogOpen(false);
} catch (error) {
console.error("Failed to share space invite", error);
- setInviteShareError("Couldn't share invite. Please try again.");
} finally {
setIsInviteSharing(false);
}
@@ -2505,14 +2486,24 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
<Box
component="button"
type="button"
- onClick={openInviteDialog}
+ disabled={
+ !onShareProfileLink ||
+ isInviteSharing
+ }
+ onClick={() =>
+ void shareInviteLink()
+ }
sx={{
alignItems: "center",
bgcolor: "#F2F2F2",
border: 0,
borderRadius: "18px",
color: textBase,
- cursor: "pointer",
+ cursor:
+ onShareProfileLink &&
+ !isInviteSharing
+ ? "pointer"
+ : "default",
display: "inline-flex",
fontFamily:
'"Inter Variable", Inter, sans-serif',
@@ -2525,17 +2516,25 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
pointerEvents: "auto",
px: "14px",
whiteSpace: "nowrap",
+ "&:disabled": {
+ opacity: 0.45,
+ },
"&:focus-visible": {
outline: `2px solid ${green}`,
outlineOffset: 2,
},
- "&:hover": {
- bgcolor: "#E8E8E8",
- },
+ "&:hover":
+ onShareProfileLink &&
+ !isInviteSharing
+ ? {
+ bgcolor:
+ "#E8E8E8",
+ }
+ : undefined,
}}
>
<ShareIcon />
- Invite friends
+ Share invite
</Box>
)}
</Box>
@@ -2567,15 +2566,6 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
)}
</Box>
</Box>
- {showInviteEmptyState && (
- <SpaceInviteFriendsDialog
- errorMessage={inviteShareError}
- open={isInviteDialogOpen}
- sharing={isInviteSharing}
- onClose={closeInviteDialog}
- onShare={() => void shareInviteLink()}
- />
- )}
</>
);
};