π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add social feed empty state
Anand Baburajan520f15f79f32
diff --git a/web/apps/social/src/pages/index.tsx b/web/apps/social/src/pages/index.tsxindex 0335e08e63..23fc62a1d7 100644--- a/web/apps/social/src/pages/index.tsx+++ b/web/apps/social/src/pages/index.tsx@@ -50,6 +50,8 @@ type OnboardingEntrySource = "direct" | "add-friend-link";const onboardingSourceSearchParam = "onboardingSource";const addFriendLinkOnboardingSource: OnboardingEntrySource = "add-friend-link";+const showMockFriends =+ process.env.NEXT_PUBLIC_HIDE_SOCIAL_MOCK_FRIENDS != "true";const samplePublicProfileData = {avatarUrl: "/images/sample-avatar.jpg",@@ -110,7 +112,9 @@ const Page: React.FC = () => {const [routeMode, setRouteMode] = useState<RouteMode>({ kind: "checking" });const [screen, setScreen] = useState<Screen>("onboarding");const [email, setEmail] = useState("[email protected]");- const [friends, setFriends] = useState(sampleFriends);+ const [friends, setFriends] = useState(() =>+ showMockFriends ? sampleFriends : [],+ );const [onboardingEntrySource, setOnboardingEntrySource] =useState<OnboardingEntrySource>("direct");const [profile, setProfile] = useState<SetupProfile | null>(null);@@ -264,6 +268,7 @@ const Page: React.FC = () => {)}{screen == "home" && profile && (<HomeScreen+ friendsCount={friends.length}profile={profile}onOpenFriend={(friendID) =>openFriendProfile(friendID, "home")@@ -315,7 +320,7 @@ const Page: React.FC = () => {setProfile(null);setOnboardingEntrySource("direct");setSelectedFriendID(null);- setFriends(sampleFriends);+ setFriends(showMockFriends ? sampleFriends : []);setScreen("onboarding");}}/>diff --git a/web/apps/social/src/screens/HomeScreen.tsx b/web/apps/social/src/screens/HomeScreen.tsxindex be57e57684..fa45c7ffb9 100644--- a/web/apps/social/src/screens/HomeScreen.tsx+++ b/web/apps/social/src/screens/HomeScreen.tsx@@ -12,7 +12,9 @@ import {} from "components/SocialFileViewer";import { EnteLogo } from "ente-base/components/EnteLogo";import React, { useState } from "react";+import { ShareIcon } from "screens/ShareProfileLinkScreen";import type { SetupProfile } from "screens/SetupProfileScreen";+import { profileLinkForUsername } from "utils/profileLink";import { firstNameFrom, formatSocialDate } from "utils/socialDisplay";export const homeBackground = "#FFFFFF";@@ -26,6 +28,8 @@ const minutesAgo = (minutes: number) => Date.now() - minutes * 60 * 1000;const hoursAgo = (hours: number) => minutesAgo(hours * 60);const daysAgo = (days: number) => hoursAgo(days * 24);const sampleFeedPhotoAspectRatio = 900 / 680;+const showMockFeedData =+ process.env.NEXT_PUBLIC_SHOW_SOCIAL_MOCK_FEED == "true";type PostActionPhase = "posting" | "posted";const sampleFeedItems = [@@ -88,6 +92,7 @@ const sampleFeedItems = [];interface HomeScreenProps {+ friendsCount: number;onOpenFriend?: (friendID: string) => void;onOpenProfile?: () => void;profile: SetupProfile;@@ -307,6 +312,7 @@ const FeedItem: React.FC<FeedItemProps> = ({};export const HomeScreen: React.FC<HomeScreenProps> = ({+ friendsCount,onOpenFriend,onOpenProfile,profile,@@ -317,6 +323,13 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({useState<PostActionPhase | null>(null);const postInputRef = React.useRef<HTMLInputElement | null>(null);const selectedPhotoFriendID = selectedPhoto?.friendID;+ const feedItems = showMockFeedData ? sampleFeedItems : [];+ const hasFeedItems = feedItems.length > 0;+ const emptyFeedMessage =+ friendsCount == 0+ ? "When you add friends, their posts will appear here."+ : "When your friends share posts, they'll appear here.";+ const profileLink = profileLinkForUsername(profile.username.trim());const isPostActionPosting = postActionPhase == "posting";const isPostActionPosted = postActionPhase == "posted";const postActionFeedbackPhase: SocialActionPhase | null =@@ -333,6 +346,20 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({.join("");const openPostPhotoPicker = () => postInputRef.current?.click();+ const shareProfileLink = async () => {+ 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 handlePostPhotoSelect: React.ChangeEventHandler<HTMLInputElement> = (event,) => {@@ -508,27 +535,109 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({</Box><Boxsx={{+ boxSizing: "border-box",display: "flex",flexDirection: "column",- gap: "36px",- mt: "22px",- pb: "16px",+ gap: hasFeedItems ? "36px" : 0,+ justifyContent: hasFeedItems ? "flex-start" : "center",+ minHeight: "calc(100svh - 56px)",+ pb: hasFeedItems ? "16px" : "56px",+ pt: hasFeedItems ? "22px" : 0,width: "100%",}}>- {sampleFeedItems.map((item) => (- <FeedItem- key={`${item.name}-${item.imageUrl}`}- aspectRatio={item.aspectRatio}- avatarUrl={item.avatarUrl}- friendID={item.friendID}- imageUrl={item.imageUrl}- name={item.name}- onOpenFriend={onOpenFriend}- onOpenPhoto={setSelectedPhoto}- timestampMs={item.timestampMs}- />- ))}+ {hasFeedItems ? (+ feedItems.map((item) => (+ <FeedItem+ key={`${item.name}-${item.imageUrl}`}+ aspectRatio={item.aspectRatio}+ avatarUrl={item.avatarUrl}+ friendID={item.friendID}+ imageUrl={item.imageUrl}+ name={item.name}+ onOpenFriend={onOpenFriend}+ onOpenPhoto={setSelectedPhoto}+ timestampMs={item.timestampMs}+ />+ ))+ ) : (+ <Box+ sx={{+ alignItems: "center",+ display: "flex",+ flexDirection: "column",+ justifyContent: "center",+ px: 3,+ textAlign: "center",+ width: "100%",+ }}+ >+ <Box+ component="img"+ alt=""+ src="/images/share-memories.svg"+ sx={{+ display: "block",+ height: "auto",+ width: 156,+ "@media (max-width: 340px)": {+ width: 140,+ },+ }}+ />+ <Box+ component="p"+ sx={{+ color: textSecondary,+ fontFamily:+ '"Inter Variable", Inter, sans-serif',+ fontSize: 14,+ fontWeight: 500,+ lineHeight: "20px",+ m: 0,+ mt: "36px",+ maxWidth: 220,+ }}+ >+ {emptyFeedMessage}+ </Box>+ {friendsCount == 0 && (+ <Box+ component="button"+ type="button"+ onClick={shareProfileLink}+ sx={{+ alignItems: "center",+ bgcolor: "#F2F2F2",+ border: 0,+ borderRadius: "18px",+ color: textBase,+ cursor: "pointer",+ display: "inline-flex",+ fontFamily:+ '"Inter Variable", Inter, sans-serif',+ fontSize: 13,+ fontWeight: 600,+ gap: "6px",+ height: 36,+ justifyContent: "center",+ lineHeight: "18px",+ mt: "18px",+ px: "14px",+ whiteSpace: "nowrap",+ "&:focus-visible": {+ outline: `2px solid ${green}`,+ outlineOffset: 2,+ },+ "&:hover": { bgcolor: "#E8E8E8" },+ }}+ >+ <ShareIcon />+ Share link+ </Box>+ )}+ </Box>+ )}</Box>{selectedPhoto && (<SocialFileViewerdiff --git a/web/apps/social/src/screens/ProfileScreen.tsx b/web/apps/social/src/screens/ProfileScreen.tsxindex e7495bf5cf..8ce3686fab 100644--- a/web/apps/social/src/screens/ProfileScreen.tsx+++ b/web/apps/social/src/screens/ProfileScreen.tsx@@ -200,7 +200,8 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({0,);const isProfileActionsOpen = Boolean(profileActionsAnchor);- const canOpenFriends = isOwnerProfile && Boolean(onOpenFriends);+ const canOpenFriends =+ isOwnerProfile && friendsCount > 0 && Boolean(onOpenFriends);const closeProfileActions = () => setProfileActionsAnchor(null);diff --git a/web/apps/social/src/screens/ShareProfileLinkScreen.tsx b/web/apps/social/src/screens/ShareProfileLinkScreen.tsxindex 5e3b3ac87e..4ca7dfc68c 100644--- a/web/apps/social/src/screens/ShareProfileLinkScreen.tsx+++ b/web/apps/social/src/screens/ShareProfileLinkScreen.tsx@@ -1,3 +1,5 @@+import { Share08Icon } from "@hugeicons/core-free-icons";+import { HugeiconsIcon } from "@hugeicons/react";import { Box } from "@mui/material";import React, { useState } from "react";import type { SetupProfile } from "screens/SetupProfileScreen";@@ -44,21 +46,7 @@ const BackIcon: React.FC = () => ();export const ShareIcon: React.FC = () => (- <Box- component="svg"- viewBox="0 0 24 24"- aria-hidden- sx={{ display: "block", height: 20, width: 20 }}- >- <path- d="M12 15.5V4.75M12 4.75L8.25 8.5M12 4.75L15.75 8.5M6.5 11.5V17.5C6.5 18.6 7.4 19.5 8.5 19.5H15.5C16.6 19.5 17.5 18.6 17.5 17.5V11.5"- fill="none"- stroke="currentColor"- strokeLinecap="round"- strokeLinejoin="round"- strokeWidth="1.8"- />- </Box>+ <HugeiconsIcon icon={Share08Icon} size={18} strokeWidth={1.8} />);export const LinkIcon: React.FC = () => (