π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Wire social activity profile navigation
Anand Baburajan7d8d846a3ab6
diff --git a/web/apps/social/src/components/SocialFileViewer.tsx b/web/apps/social/src/components/SocialFileViewer.tsxindex b9f66bcb7f..75b74c2f27 100644--- a/web/apps/social/src/components/SocialFileViewer.tsx+++ b/web/apps/social/src/components/SocialFileViewer.tsx@@ -69,6 +69,7 @@ interface SocialFileViewerProps {initialScreen?: SocialViewerInitialScreen;onClose: () => void;onDeletePost?: () => void;+ onOpenFriend?: (friendID: string) => void;onOpenProfile?: () => void;photo: SocialViewerPhoto;}@@ -87,6 +88,7 @@ interface SocialComment {interface SocialLiker {id: string;avatarUrl?: string | null;+ friendID?: string;name: string;}@@ -106,7 +108,7 @@ const microsAgo = (durationMs: number) =>const mockComments: SocialComment[] = [{id: "kabir-plan",- author: "Kabir Mehta",+ author: "Kabir Menon",avatarUrl: "/images/sample-feed-1.jpg",createdAtMicros: microsAgo(6 * minuteMs),text: "This is the overlook near the old forest road, right?",@@ -139,7 +141,7 @@ const mockComments: SocialComment[] = [},{id: "kabir-followup",- author: "Kabir Mehta",+ author: "Kabir Menon",avatarUrl: "/images/sample-feed-1.jpg",createdAtMicros: microsAgo(4 * minuteMs),parentCommentID: "you-kabir-plan",@@ -217,7 +219,7 @@ const mockComments: SocialComment[] = [},{id: "devika",- author: "Devika Iyer",+ author: "Isha Mehta",avatarUrl: "/images/sample-feed-2.jpg",createdAtMicros: microsAgo(74 * minuteMs),text: "Saving this for the weekend plan.",@@ -233,7 +235,7 @@ const mockComments: SocialComment[] = [},{id: "devika-route",- author: "Devika Iyer",+ author: "Isha Mehta",avatarUrl: "/images/sample-feed-2.jpg",createdAtMicros: microsAgo(70 * minuteMs),parentCommentID: "you-reply-devika",@@ -250,7 +252,7 @@ const mockComments: SocialComment[] = [},{id: "kabir",- author: "Kabir Mehta",+ author: "Kabir Menon",avatarUrl: "/images/sample-feed-1.jpg",createdAtMicros: microsAgo(3 * hourMs),text: "Looks peaceful. Was it crowded?",@@ -266,7 +268,7 @@ const mockComments: SocialComment[] = [},{id: "kabir-crowd-2",- author: "Kabir Mehta",+ author: "Kabir Menon",avatarUrl: "/images/sample-feed-1.jpg",createdAtMicros: microsAgo(3 * hourMs - 8 * minuteMs),parentCommentID: "you-crowd-reply",@@ -283,21 +285,21 @@ const mockComments: SocialComment[] = [},{id: "samar",- author: "Samar Jain",+ author: "Aparna Bhatnagar",avatarUrl: "/images/sample-feed-4.jpg",createdAtMicros: microsAgo(3 * dayMs),text: "The composition makes it feel cinematic.",},{id: "samar-2",- author: "Samar Jain",+ author: "Aparna Bhatnagar",avatarUrl: "/images/sample-feed-4.jpg",createdAtMicros: microsAgo(3 * dayMs - 8 * minuteMs),text: "Also love that the sky is not overdone.",},{id: "leena",- author: "Leena Shah",+ author: "Riya Kapoor",avatarUrl: "/images/sample-feed-6.jpg",createdAtMicros: microsAgo(8 * dayMs),text: "Need the exact location for this one.",@@ -313,7 +315,7 @@ const mockComments: SocialComment[] = [},{id: "leena-final",- author: "Leena Shah",+ author: "Riya Kapoor",avatarUrl: "/images/sample-feed-6.jpg",createdAtMicros: microsAgo(8 * dayMs - 39 * minuteMs),parentCommentID: "you-reply-leena",@@ -322,24 +324,51 @@ const mockComments: SocialComment[] = [];const mockPhotoLikers: SocialLiker[] = [- { id: "mira", avatarUrl: "/images/sample-feed-3.jpg", name: "Mira Sen" },+ {+ id: "mira",+ avatarUrl: "/images/sample-feed-3.jpg",+ friendID: "mira-sen",+ name: "Mira Sen",+ },{id: "kabir",avatarUrl: "/images/sample-feed-1.jpg",- name: "Kabir Mehta",+ friendID: "kabir-menon",+ name: "Kabir Menon",},{id: "devika",avatarUrl: "/images/sample-feed-2.jpg",- name: "Devika Iyer",+ friendID: "isha-mehta",+ name: "Isha Mehta",},{id: "nikhil",avatarUrl: "/images/sample-feed-5.jpg",+ friendID: "nikhil-rao",name: "Nikhil Rao",},];+const friendIDForPersonName = (name: string): string | undefined => {+ switch (name.trim()) {+ case "Aparna Bhatnagar":+ return "aparna-bhatnagar";+ case "Isha Mehta":+ return "isha-mehta";+ case "Kabir Menon":+ return "kabir-menon";+ case "Riya Kapoor":+ return "riya-kapoor";+ case "Mira Sen":+ return "mira-sen";+ case "Nikhil Rao":+ return "nikhil-rao";+ default:+ return undefined;+ }+};+const commentAuthorKey = (comment: SocialComment) =>comment.isOwner ? "current-user" : comment.author;@@ -530,6 +559,7 @@ interface CommentItemProps {isLiked: boolean;isLastInSequence: boolean;onOpenActions: (comment: SocialComment, anchorEl: HTMLElement) => void;+ onOpenAuthorProfile?: () => void;parentComment?: SocialComment;showHeader: boolean;showOwnTimestamp: boolean;@@ -541,6 +571,7 @@ const CommentItem: React.FC<CommentItemProps> = ({isLiked,isLastInSequence,onOpenActions,+ onOpenAuthorProfile,parentComment,showHeader,showOwnTimestamp,@@ -590,14 +621,29 @@ const CommentItem: React.FC<CommentItemProps> = ({>{showHeader && (<Box+ component={onOpenAuthorProfile ? "button" : "div"}+ type={onOpenAuthorProfile ? "button" : undefined}+ onClick={onOpenAuthorProfile}sx={{alignItems: "center",+ appearance: "none",+ bgcolor: "transparent",+ border: 0,+ color: "inherit",+ cursor: onOpenAuthorProfile ? "pointer" : "default",display: "flex",gap: "10px",maxWidth: "min(calc(100vw - 32px), 360px)",mb: "10px",minWidth: 0,+ p: 0,+ textAlign: "left",width: "100%",+ "&:focus-visible": {+ borderRadius: "18px",+ outline: `2px solid ${green}`,+ outlineOffset: 3,+ },}}><SocialAvatar@@ -621,7 +667,7 @@ const CommentItem: React.FC<CommentItemProps> = ({fontFamily:'"Inter Variable", Inter, sans-serif',fontSize: 14,- fontWeight: 750,+ fontWeight: 600,lineHeight: "20px",minWidth: 0,overflow: "hidden",@@ -808,6 +854,7 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({initialScreen = "photo",onClose,onDeletePost,+ onOpenFriend,onOpenProfile,photo,}) => {@@ -1025,6 +1072,11 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({const closeCommentActions = () => setCommentContextMenu(null);+ const openFriendProfile = (friendID: string) => {+ setCommentContextMenu(null);+ onOpenFriend?.(friendID);+ };+const handleCommentAction = (action: "like" | "reply" | "delete") => {if (!commentContextMenu) return;@@ -1862,57 +1914,96 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({No likes yet</Box>) : (- photoLikers.map((liker) => (- <Box- component="li"- key={liker.id}- sx={{- alignItems: "center",- borderRadius: "12px",- boxSizing: "border-box",- display: "flex",- gap: "12px",- minHeight: 52,- px: "2px",- py: "8px",- width: "100%",- }}- >- <SocialAvatar- avatarUrl={liker.avatarUrl}- name={liker.name}- size={36}- />- <Box- sx={{- color: textBase,- flex: "1 1 auto",- fontFamily:- '"Inter Variable", Inter, sans-serif',- fontSize: 14,- fontWeight: 650,- lineHeight: "20px",- minWidth: 0,- overflow: "hidden",- textOverflow: "ellipsis",- whiteSpace: "nowrap",- }}- >- {liker.name}- </Box>+ photoLikers.map((liker) => {+ const likerName = firstNameFrom(liker.name);+ const friendID =+ liker.friendID ??+ friendIDForPersonName(liker.name);+ const canOpenFriend = Boolean(+ friendID && onOpenFriend,+ );+ const openLikerProfile =+ canOpenFriend && friendID+ ? () => openFriendProfile(friendID)+ : undefined;++ return (<Box- aria-hidden- sx={{- alignItems: "center",- display: "flex",- flexShrink: 0,- justifyContent: "center",- }}+ component="li"+ key={liker.id}+ sx={{ listStyle: "none" }}>- <HeartFilledIcon />+ <Box+ component={+ canOpenFriend ? "button" : "div"+ }+ type={+ canOpenFriend+ ? "button"+ : undefined+ }+ onClick={openLikerProfile}+ sx={{+ alignItems: "center",+ appearance: "none",+ bgcolor: "transparent",+ border: 0,+ borderRadius: "12px",+ boxSizing: "border-box",+ color: "inherit",+ cursor: canOpenFriend+ ? "pointer"+ : "default",+ display: "flex",+ gap: "12px",+ minHeight: 52,+ px: "2px",+ py: "8px",+ textAlign: "left",+ width: "100%",+ "&:focus-visible": {+ outline: `2px solid ${green}`,+ outlineOffset: 2,+ },+ }}+ >+ <SocialAvatar+ avatarUrl={liker.avatarUrl}+ name={likerName}+ size={36}+ />+ <Box+ sx={{+ color: textBase,+ flex: "1 1 auto",+ fontFamily:+ '"Inter Variable", Inter, sans-serif',+ fontSize: 14,+ fontWeight: 600,+ lineHeight: "20px",+ minWidth: 0,+ overflow: "hidden",+ textOverflow: "ellipsis",+ whiteSpace: "nowrap",+ }}+ >+ {likerName}+ </Box>+ <Box+ aria-hidden+ sx={{+ alignItems: "center",+ display: "flex",+ flexShrink: 0,+ justifyContent: "center",+ }}+ >+ <HeartFilledIcon />+ </Box>+ </Box></Box>- </Box>- ))+ );+ }))}</Box></Box>@@ -2064,6 +2155,9 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({commentGroupTimeThresholdMicros;const isFirstInSequence = !isSameSequenceAsPrev;const isLastInSequence = !isSameSequenceAsNext;+ const authorFriendID = comment.isOwner+ ? undefined+ : friendIDForPersonName(comment.author);return (<CommentItem@@ -2078,6 +2172,14 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({comment.id,)}onOpenActions={openCommentActions}+ onOpenAuthorProfile={+ authorFriendID && onOpenFriend+ ? () =>+ openFriendProfile(+ authorFriendID,+ )+ : undefined+ }parentComment={getParentComment(comment.parentCommentID,comments,diff --git a/web/apps/social/src/pages/index.tsx b/web/apps/social/src/pages/index.tsxindex c3402d9221..466f5364ad 100644--- a/web/apps/social/src/pages/index.tsx+++ b/web/apps/social/src/pages/index.tsx@@ -52,7 +52,7 @@ type Screen =| "settings";type ProfileBackScreen = "login" | "verify-email";-type FriendProfileBackScreen = "friends" | "home" | "notifications";+type FriendProfileBackScreen = "friends" | "home" | "notifications" | "profile";type OnboardingEntrySource = "direct" | "add-friend-link";const onboardingSourceSearchParam = "onboardingSource";@@ -303,6 +303,9 @@ const Page: React.FC = () => {friendsCount={friends.length}profile={profile}onBack={() => setScreen("home")}+ onOpenFriend={(friendID) =>+ openFriendProfile(friendID, "profile")+ }onOpenFriends={() => setScreen("friends")}onOpenSettings={() => setScreen("settings")}/>@@ -341,6 +344,12 @@ const Page: React.FC = () => {username: selectedFriend.username,}}onBack={() => setScreen(friendProfileBackScreen)}+ onOpenFriend={(friendID) =>+ openFriendProfile(+ friendID,+ friendProfileBackScreen,+ )+ }/>)}{screen == "settings" && profile && (diff --git a/web/apps/social/src/screens/HomeScreen.tsx b/web/apps/social/src/screens/HomeScreen.tsxindex 7671c5dbf0..aab2832e13 100644--- a/web/apps/social/src/screens/HomeScreen.tsx+++ b/web/apps/social/src/screens/HomeScreen.tsx@@ -274,6 +274,8 @@ const FeedItem: React.FC<FeedItemProps> = ({initialScreen,);const visibleLikeCount = likeCount + (isLiked ? 1 : 0);+ const hasVisibleLikes = visibleLikeCount > 0;+ const hasComments = commentCount > 0;const handleLikeClick = () => {if (likePopTimeoutRef.current != null)window.clearTimeout(likePopTimeoutRef.current);@@ -493,40 +495,46 @@ const FeedItem: React.FC<FeedItemProps> = ({strokeWidth={1.8}/></Box>+ {hasVisibleLikes && (+ <Box+ component="button"+ type="button"+ aria-label={`View ${visibleLikeCount} ${+ visibleLikeCount == 1 ? "like" : "likes"+ }`}+ onClick={() => openPhoto("likes")}+ sx={{+ appearance: "none",+ bgcolor: "transparent",+ border: 0,+ borderRadius: "8px",+ color: textBase,+ cursor: onOpenPhoto ? "pointer" : "default",+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 13,+ fontWeight: 500,+ lineHeight: "18px",+ p: "4px 0",+ "&:focus-visible": {+ outline: `2px solid ${green}`,+ outlineOffset: 2,+ },+ "&:hover": { color: green },+ }}+ >+ {visibleLikeCount}+ </Box>+ )}<Boxcomponent="button"type="button"- aria-label={`View ${visibleLikeCount} ${- visibleLikeCount == 1 ? "like" : "likes"- }`}- onClick={() => openPhoto("likes")}- sx={{- appearance: "none",- bgcolor: "transparent",- border: 0,- borderRadius: "8px",- color: textBase,- cursor: onOpenPhoto ? "pointer" : "default",- fontFamily: '"Inter Variable", Inter, sans-serif',- fontSize: 13,- fontWeight: 500,- lineHeight: "18px",- p: "4px 0",- "&:focus-visible": {- outline: `2px solid ${green}`,- outlineOffset: 2,- },- "&:hover": { color: green },- }}- >- {visibleLikeCount}- </Box>- <Box- component="button"- type="button"- aria-label={`View ${commentCount} ${- commentCount == 1 ? "comment" : "comments"- }`}+ aria-label={+ hasComments+ ? `View ${commentCount} ${+ commentCount == 1 ? "comment" : "comments"+ }`+ : "Comment on post"+ }onClick={() => openPhoto("comments")}sx={{alignItems: "center",@@ -556,7 +564,7 @@ const FeedItem: React.FC<FeedItemProps> = ({size={20}strokeWidth={1.8}/>- {commentCount}+ {hasComments && commentCount}</Box></Box></Box>@@ -999,6 +1007,14 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({initialScreen={selectedViewerScreen}photo={selectedPhoto}onClose={closeSelectedPhoto}+ onOpenFriend={+ onOpenFriend+ ? (friendID) => {+ closeSelectedPhoto();+ onOpenFriend(friendID);+ }+ : undefined+ }onOpenProfile={selectedPhotoFriendID && onOpenFriend? () => {diff --git a/web/apps/social/src/screens/NotificationsScreen.tsx b/web/apps/social/src/screens/NotificationsScreen.tsxindex 2a6ac2c85d..409c61c4b0 100644--- a/web/apps/social/src/screens/NotificationsScreen.tsx+++ b/web/apps/social/src/screens/NotificationsScreen.tsx@@ -7,7 +7,7 @@ import { Box } from "@mui/material";import type { FriendProfile } from "data/friends";import { formatTimeAgo } from "ente-base/date";import React from "react";-import { initialsFor } from "utils/socialDisplay";+import { firstNameFrom, initialsFor } from "utils/socialDisplay";export const notificationsBackground = "#FFFFFF";@@ -267,31 +267,31 @@ const actionForNotification = (): { icon: React.ReactNode; label: string } => {switch (type) {case "liked-post":- return { icon: <LikedPhotoIcon />, label: "Liked your post" };+ return { icon: <LikedPhotoIcon />, label: "liked your post" };case "commented-post":return {icon: <CommentedPhotoIcon />,- label: "Commented on your post",+ label: "commented on your post",};case "liked-comment":return {icon: <LikedCommentIcon />,- label: "Liked a comment",+ label: "liked a comment",};case "liked-your-comment":return {icon: <LikedCommentIcon />,- label: "Liked your comment",+ label: "liked your comment",};case "replied-comment":return {icon: <RepliedCommentIcon />,- label: "Replied to a comment",+ label: "replied to a comment",};case "added-friend":return {icon: <UserAddNotificationIcon />,- label: "Added you as a friend",+ label: "added you as a friend",};}};@@ -303,7 +303,10 @@ const NotificationRow: React.FC<NotificationRowProps> = ({const { icon, label } = actionForNotification(notification.type);const actorName =notification.actor.fullName.trim() || notification.actor.username;- const actorInitials = initialsFor(actorName || notification.actor.username);+ const actorFirstName = firstNameFrom(actorName);+ const actorInitials = initialsFor(+ actorFirstName || notification.actor.username,+ );const timestampMicros = microsForTimestamp(notification.timestampMs);const timestampDateTime = new Date(Math.floor(timestampMicros / 1000),@@ -443,7 +446,7 @@ const NotificationRow: React.FC<NotificationRowProps> = ({color: textBase,fontFamily: '"Inter Variable", Inter, sans-serif',fontSize: 14,- fontWeight: 600,+ fontWeight: 500,lineHeight: "19px",minWidth: 0,overflow: "hidden",@@ -451,9 +454,14 @@ const NotificationRow: React.FC<NotificationRowProps> = ({whiteSpace: "nowrap",}}>- {actorName}+ <Box component="span" sx={{ fontWeight: 600 }}>+ {actorFirstName}+ </Box>{" "}+ {label}</Box><Box+ component="time"+ dateTime={timestampDateTime}sx={{color: textSoft,fontFamily: '"Inter Variable", Inter, sans-serif',@@ -466,27 +474,7 @@ const NotificationRow: React.FC<NotificationRowProps> = ({whiteSpace: "nowrap",}}>- {label}- <Box- component="span"- aria-hidden- sx={{- color: textSoft,- px: "5px",- }}- >- Β·- </Box>- <Box- component="time"- dateTime={timestampDateTime}- sx={{- color: textSoft,- display: "inline",- }}- >- {timestampLabel}- </Box>+ {timestampLabel}</Box></Box>{notification.postThumbnailUrl && (diff --git a/web/apps/social/src/screens/ProfileScreen.tsx b/web/apps/social/src/screens/ProfileScreen.tsxindex 1fd5161fac..1d861c8e65 100644--- a/web/apps/social/src/screens/ProfileScreen.tsx+++ b/web/apps/social/src/screens/ProfileScreen.tsx@@ -202,6 +202,7 @@ interface ProfileScreenProps {headerVariant?: "friend" | "owner" | "public";onAddFriend?: () => void;onBack?: () => void;+ onOpenFriend?: (friendID: string) => void;onOpenFriends?: () => void;onOpenSettings?: () => void;profile: SetupProfile;@@ -212,6 +213,7 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({headerVariant = "owner",onAddFriend,onBack,+ onOpenFriend,onOpenFriends,onOpenSettings,profile,@@ -1194,6 +1196,14 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({onDeletePost={isOwnerProfile ? deleteSelectedPost : undefined}+ onOpenFriend={+ onOpenFriend+ ? (friendID) => {+ setSelectedPost(null);+ onOpenFriend(friendID);+ }+ : undefined+ }onOpenProfile={() => setSelectedPost(null)}/>)}