π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Update Space invite entry points
Anand Baburajan5b9c27bb5d47
diff --git a/web/apps/space/src/pages/app/friends/index.tsx b/web/apps/space/src/pages/app/friends/index.tsxindex d085f31104..8c238ed42d 100644--- a/web/apps/space/src/pages/app/friends/index.tsx+++ b/web/apps/space/src/pages/app/friends/index.tsx@@ -4,6 +4,7 @@ import { useRouter } from "next/router";import React, { useEffect } from "react";import { FriendsScreen, friendsBackground } from "screens/FriendsScreen";import {+ createCurrentProfileLink,loadCurrentFriendAvatarURL,loadCurrentSpaceFriends,removeCurrentSpaceFriend,@@ -56,6 +57,11 @@ const Page: React.FC = () => {onOpenFriend={(friendID) =>void router.push(spaceRoutes.friend(friendID))}+ onShareProfileLink={async () => {+ if (!profile.spaceId) throw new Error("Missing space.");+ return (await createCurrentProfileLink(profile.spaceId))+ .url;+ }}onUnfriend={async (friendID) => {const friend = friends.find((candidate) => candidate.id == friendID,diff --git a/web/apps/space/src/pages/app/profile.tsx b/web/apps/space/src/pages/app/profile.tsxindex 8dd5b7fd07..e06c6cfece 100644--- a/web/apps/space/src/pages/app/profile.tsx+++ b/web/apps/space/src/pages/app/profile.tsx@@ -5,7 +5,6 @@ import React, { useEffect, useMemo, useState } from "react";import { ProfileScreen, profileBackground } from "screens/ProfileScreen";import {createCurrentPhotoPost,- createCurrentProfileLink,deleteCurrentPost,loadCurrentSpaceFriendsCount,loadCurrentSpacePostAssetURL,@@ -191,11 +190,6 @@ const Page: React.FC = () => {onOpenSettings={() => void router.push(spaceRoutes.settings)}onLoadPostImage={loadCurrentSpacePostAssetURL}onSetPostLiked={setCurrentPostLiked}- onShareProfileLink={async () => {- if (!profile.spaceId) throw new Error("Missing space.");- return (await createCurrentProfileLink(profile.spaceId))- .url;- }}/></>);diff --git a/web/apps/space/src/screens/FriendsScreen.tsx b/web/apps/space/src/screens/FriendsScreen.tsxindex b71ee9743e..92eed815cb 100644--- a/web/apps/space/src/screens/FriendsScreen.tsx+++ b/web/apps/space/src/screens/FriendsScreen.tsx@@ -1,10 +1,12 @@import {ArrowLeft02Icon,MoreVerticalIcon,+ Share08Icon,+ UserAdd02Icon,UserRemove01Icon,} from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";-import { Box, Menu, MenuItem, Skeleton } from "@mui/material";+import { Box, Dialog, Menu, MenuItem, Skeleton } from "@mui/material";import { ConfirmationActionSheet } from "components/ConfirmationActionSheet";import {spaceActionDoneDurationMs,@@ -37,6 +39,7 @@ interface FriendsScreenProps {onLoadFriendAvatar?: (friend: FriendProfile) => Promise<string | null>;onBack?: () => void;onOpenFriend?: (friendID: string) => void;+ onShareProfileLink?: () => Promise<string>;onUnfriend?: (friendID: string) => Promise<void> | void;}@@ -243,12 +246,11 @@ const FriendRow: React.FC<FriendRowProps> = ({alignItems: "center",bgcolor: "transparent",border: 0,- borderRadius: "50%",color: textBase,cursor: "pointer",display: "flex",height: spaceTouchTargetSize,- justifyContent: "center",+ justifyContent: "flex-end",justifySelf: "flex-end",p: 0,width: spaceTouchTargetSize,@@ -256,7 +258,6 @@ const FriendRow: React.FC<FriendRowProps> = ({outline: `2px solid ${green}`,outlineOffset: 2,},- "&:hover": { bgcolor: "rgba(0, 0, 0, 0.035)" },}}><HugeiconsIcon@@ -325,11 +326,148 @@ 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();++ return (+ <Dialog+ open={open}+ onClose={sharing ? undefined : onClose}+ maxWidth={false}+ aria-labelledby={titleID}+ slotProps={{+ backdrop: { sx: { backgroundColor: "rgba(0, 0, 0, 0.48)" } },+ paper: {+ sx: {+ bgcolor: friendsBackground,+ borderRadius: "20px",+ boxShadow: "0 18px 48px rgba(0, 0, 0, 0.18)",+ boxSizing: "border-box",+ m: "16px",+ maxWidth: 342,+ p: "24px 20px 20px",+ width: "calc(100vw - 32px)",+ },+ },+ }}+ >+ <Box+ component="h2"+ id={titleID}+ sx={{+ color: textBase,+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 18,+ fontWeight: 650,+ lineHeight: "24px",+ m: 0,+ 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: "18px",+ boxShadow: "0 12px 32px rgba(0, 0, 0, 0.18)",+ color: "#FFFFFF",+ cursor: sharing ? "default" : "pointer",+ display: "flex",+ gap: "10px",+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 15,+ fontWeight: 650,+ justifyContent: "center",+ lineHeight: "20px",+ minHeight: 48,+ px: "16px",+ py: "10px",+ width: "100%",+ "&:disabled": { opacity: 0.7 },+ "&:focus-visible": {+ outline: "2px solid rgba(0 0 0 / 0.72)",+ outlineOffset: 2,+ },+ }}+ >+ <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>+ </Dialog>+ );+};+export const FriendsScreen: React.FC<FriendsScreenProps> = ({friends,onLoadFriendAvatar,onBack,onOpenFriend,+ onShareProfileLink,onUnfriend,}) => {const [friendToUnfriend, setFriendToUnfriend] =@@ -342,6 +480,11 @@ 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());@@ -427,6 +570,48 @@ 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();++ 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);+ setIsInviteDialogOpen(false);+ } catch (error) {+ console.error("Failed to share space invite", error);+ setInviteShareError("Couldn't share invite. Please try again.");+ } finally {+ setIsInviteSharing(false);+ }+ };+return (<Boxcomponent="main"@@ -506,6 +691,39 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({>Friends</Box>+ <Box+ component="button"+ type="button"+ aria-label="Invite friends"+ disabled={!onShareProfileLink}+ onClick={openInviteDialog}+ sx={{+ alignItems: "center",+ bgcolor: "transparent",+ border: 0,+ color: textBase,+ cursor: onShareProfileLink+ ? "pointer"+ : "default",+ display: "flex",+ height: spaceTouchTargetSize,+ justifyContent: "flex-end",+ justifySelf: "flex-end",+ p: 0,+ width: spaceTouchTargetSize,+ "&:disabled": { opacity: 0.45 },+ "&:focus-visible": {+ outline: `2px solid ${green}`,+ outlineOffset: 2,+ },+ }}+ >+ <HugeiconsIcon+ icon={UserAdd02Icon}+ size={22}+ strokeWidth={1.8}+ />+ </Box></Box>{friends.length > 0 ? (@@ -569,6 +787,13 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({onConfirm={confirmUnfriend}onExited={handleUnfriendSheetExited}/>+ <InviteFriendsDialog+ errorMessage={inviteShareError}+ open={isInviteDialogOpen}+ sharing={isInviteSharing}+ onClose={closeInviteDialog}+ onShare={() => void shareInviteLink()}+ /></Box>);};diff --git a/web/apps/space/src/screens/ProfileScreen.tsx b/web/apps/space/src/screens/ProfileScreen.tsxindex 8ecd09e225..96e4f54cf7 100644--- a/web/apps/space/src/screens/ProfileScreen.tsx+++ b/web/apps/space/src/screens/ProfileScreen.tsx@@ -16,7 +16,6 @@ import { EnteLogo } from "ente-base/components/EnteLogo";import { useBrowserBackClose } from "hooks/useBrowserBackClose";import React, { useState } from "react";import type { SetupProfile } from "screens/SetupProfileScreen";-import { ShareIcon } from "screens/ShareProfileLinkScreen";import type { SpacePostAsset } from "services/space";import { spaceTouchTargetSize } from "styles/touchTargets";import { createLoadedLocalPostPhoto } from "utils/localPostPhoto";@@ -404,7 +403,6 @@ interface ProfileScreenProps {onLoadPostImage?: (asset: SpacePostAsset) => Promise<string>;onReplyToPost?: (postId: number, text: string) => Promise<void>;onSetPostLiked?: (postId: number, liked: boolean) => Promise<void>;- onShareProfileLink?: () => Promise<string>;postGroups?: ProfilePostGroup[];profile: SetupProfile;}@@ -427,7 +425,6 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({onLoadPostImage,onReplyToPost,onSetPostLiked,- onShareProfileLink,postGroups = [],profile,showPostLoadingSkeleton,@@ -802,23 +799,6 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({});};- const shareProfile = 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")- return;- }- }-- await navigator.clipboard.writeText(profileLink);- };-const deleteSelectedPost = async () => {if (!selectedPost) return;@@ -1228,9 +1208,8 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({<Boxsx={{alignItems: "center",- display: "grid",- gridTemplateColumns:- "minmax(0, 1fr) minmax(0, max-content) minmax(0, 1fr)",+ display: "flex",+ justifyContent: "center",minWidth: 0,width: "100%",}}@@ -1242,7 +1221,6 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({'"Nunito", "Inter Variable", sans-serif',fontSize: 26,fontWeight: 800,- gridColumn: 2,lineHeight: "32px",maxWidth: isPublicProfile? "100%"@@ -1259,38 +1237,6 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({>{displayName}</Box>- {isOwnerProfile && (- <Box- component="button"- type="button"- aria-label="Share profile"- onClick={() => void shareProfile()}- sx={{- alignItems: "center",- bgcolor: "transparent",- border: 0,- color: textStrong,- cursor: onShareProfileLink- ? "pointer"- : "default",- display: "flex",- gridColumn: 3,- height: spaceTouchTargetSize,- justifyContent: "center",- justifySelf: "start",- ml: "4px",- p: 0,- width: spaceTouchTargetSize,- "&:focus-visible": {- borderRadius: "50%",- outline: `2px solid ${green}`,- outlineOffset: 2,- },- }}- >- <ShareIcon strokeWidth={2.2} />- </Box>- )}</Box>{isStatsLoading ? (<ProfileStatsSkeleton />