Skip to content

armgit / ente

Public Imported from GitHub
0

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

Update space invite entry points

Anand Baburajande9d7c66404b
diff --git a/web/apps/space/src/components/SpaceInviteFriendsDialog.tsx b/web/apps/space/src/components/SpaceInviteFriendsDialog.tsx
new file mode 100644
index 0000000000..a43eb4068d
--- /dev/null
+++ b/web/apps/space/src/components/SpaceInviteFriendsDialog.tsx
@@ -0,0 +1,179 @@
+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/screens/FriendsScreen.tsx b/web/apps/space/src/screens/FriendsScreen.tsx
index 4be6cb356d..b11280f7ba 100644
--- a/web/apps/space/src/screens/FriendsScreen.tsx
+++ b/web/apps/space/src/screens/FriendsScreen.tsx
@@ -1,27 +1,20 @@
import {
ArrowLeft02Icon,
MoreVerticalIcon,
- Share08Icon,
UserAdd02Icon,
UserRemove01Icon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-import {
- Box,
- Dialog,
- Menu,
- MenuItem,
- Skeleton,
- useMediaQuery,
-} from "@mui/material";
+import { Box, Menu, MenuItem, Skeleton } from "@mui/material";
import { ConfirmationActionSheet } from "components/ConfirmationActionSheet";
import {
spaceActionDoneDurationMs,
type SpaceActionPhase,
} from "components/SpaceActionFeedback";
-import { SpaceBottomSheetTransition } from "components/SpaceBottomSheetTransition";
+import { SpaceInviteFriendsDialog } from "components/SpaceInviteFriendsDialog";
import type { FriendProfile } from "data/friends";
import React, { useState } from "react";
+import { ShareIcon } from "screens/ShareProfileLinkScreen";
import { spaceTouchTargetSize } from "styles/touchTargets";
export const friendsBackground = "#FFFFFF";
@@ -334,180 +327,6 @@ const FriendRow: React.FC<FriendRowProps> = ({
);
};
-interface InviteFriendsDialogProps {
- errorMessage?: string | null;
- open: boolean;
- sharing: boolean;
- onClose: () => void;
- onShare: () => void;
-}
-
-const InviteFriendsDialog: React.FC<InviteFriendsDialogProps> = ({
- 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>
- );
-};
-
export const FriendsScreen: React.FC<FriendsScreenProps> = ({
friends,
onLoadFriendAvatar,
@@ -803,6 +622,7 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({
alignItems: "center",
color: textSoft,
display: "flex",
+ flexDirection: "column",
inset: 0,
justifyContent: "center",
fontFamily: '"Inter Variable", Inter, sans-serif',
@@ -816,6 +636,46 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({
}}
>
No friends yet
+ <Box
+ component="button"
+ type="button"
+ disabled={!onShareProfileLink}
+ onClick={openInviteDialog}
+ sx={{
+ alignItems: "center",
+ bgcolor: "#E8E8E8",
+ border: 0,
+ borderRadius: "18px",
+ color: textBase,
+ cursor: onShareProfileLink
+ ? "pointer"
+ : "default",
+ display: "inline-flex",
+ fontFamily:
+ '"Inter Variable", Inter, sans-serif',
+ fontSize: 13,
+ fontWeight: 600,
+ gap: "6px",
+ height: spaceTouchTargetSize,
+ justifyContent: "center",
+ lineHeight: "18px",
+ mt: "22px",
+ pointerEvents: "auto",
+ px: "14px",
+ whiteSpace: "nowrap",
+ "&:disabled": { opacity: 0.45 },
+ "&:focus-visible": {
+ outline: `2px solid ${green}`,
+ outlineOffset: 2,
+ },
+ "&:hover": onShareProfileLink
+ ? { bgcolor: "#DEDEDE" }
+ : undefined,
+ }}
+ >
+ <ShareIcon />
+ Invite friends
+ </Box>
</Box>
)}
</Box>
@@ -831,7 +691,7 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({
onConfirm={confirmUnfriend}
onExited={handleUnfriendSheetExited}
/>
- <InviteFriendsDialog
+ <SpaceInviteFriendsDialog
errorMessage={inviteShareError}
open={isInviteDialogOpen}
sharing={isInviteSharing}
diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsx
index 910b91e9e6..df3b8fec8a 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -13,6 +13,7 @@ import {
type SpaceViewerPhoto,
type SpaceViewerPostActionMode,
} from "components/SpaceFileViewer";
+import { SpaceInviteFriendsDialog } from "components/SpaceInviteFriendsDialog";
import { SpacePostFloatingActionButton } from "components/SpacePostFloatingActionButton";
import {
spacePostLikeButtonPop,
@@ -1299,6 +1300,11 @@ 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>
@@ -1551,20 +1557,45 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
return scheduleScrollPageToTop();
}, [feedScrollRequest]);
- const shareProfileLink = async () => {
- if (!onShareProfileLink) return;
- const profileLink = await onShareProfileLink();
- if (typeof navigator.share == "function") {
- try {
- await navigator.share({ url: profileLink });
- return;
- } catch (error) {
- if (error instanceof DOMException && error.name == "AbortError")
+ 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 (
+ error instanceof DOMException &&
+ error.name == "AbortError"
+ )
+ return;
+ }
}
- }
- await navigator.clipboard.writeText(profileLink);
+ 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);
+ }
};
const prepareSelectedPostPhoto = async (file: File) => {
@@ -2037,7 +2068,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
<Box
component="button"
type="button"
- onClick={shareProfileLink}
+ onClick={openInviteDialog}
sx={{
alignItems: "center",
bgcolor: "#E8E8E8",
@@ -2156,6 +2187,13 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
onClose={onAddedFriendToastClose}
/>
)}
+ <SpaceInviteFriendsDialog
+ errorMessage={inviteShareError}
+ open={isInviteDialogOpen}
+ sharing={isInviteSharing}
+ onClose={closeInviteDialog}
+ onShare={() => void shareInviteLink()}
+ />
</Box>
</Box>
);
diff --git a/web/apps/space/src/screens/ProfileScreen.tsx b/web/apps/space/src/screens/ProfileScreen.tsx
index 66154edfeb..3a17798e80 100644
--- a/web/apps/space/src/screens/ProfileScreen.tsx
+++ b/web/apps/space/src/screens/ProfileScreen.tsx
@@ -475,8 +475,7 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
(count, group) => count + group.items.length,
0,
);
- const canOpenFriends =
- isOwnerProfile && friendsCount > 0 && Boolean(onOpenFriends);
+ const canOpenFriends = isOwnerProfile && Boolean(onOpenFriends);
const canOpenProfileCover = isOwnerProfile && Boolean(onOpenProfileCover);
const canOpenProfilePhoto = isOwnerProfile && Boolean(onOpenProfilePhoto);
const hasProfilePosts = postsSharedCount > 0;