π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Tune Space loading states
Anand Baburajanf19a241aa273
diff --git a/web/apps/space/src/pages/app/index.tsx b/web/apps/space/src/pages/app/index.tsxindex da86690d44..33f9301dbc 100644--- a/web/apps/space/src/pages/app/index.tsx+++ b/web/apps/space/src/pages/app/index.tsx@@ -26,6 +26,8 @@ import { firstNameFrom } from "utils/spaceDisplay";import { prepareSpacePostImageFromEdit } from "utils/spacePostImage";import { spaceRoutes } from "utils/spaceRoutes";+const initialFeedSkeletonDelayMs = 350;+const Page: React.FC = () => {const router = useRouter();const {@@ -43,6 +45,14 @@ const Page: React.FC = () => {const [hasUnreadMessages, setHasUnreadMessages] = useState<boolean>();const [isFeedLoading, setIsFeedLoading] = useState(true);const [isFeedLoadingMore, setIsFeedLoadingMore] = useState(false);+ const [showInitialFeedSkeleton, setShowInitialFeedSkeleton] =+ useState(false);+ const isInitialFeedLoading =+ profileLoadStatus == "ready" &&+ Boolean(profile?.spaceId) &&+ isFeedLoading &&+ feedItems.length == 0 &&+ localFeedPosts.length == 0;const closeAddedFriendToast = React.useCallback(() => setAddedFriendToastName(undefined),[],@@ -115,6 +125,19 @@ const Page: React.FC = () => {};}, [profile?.spaceId, profileLoadStatus, setFriends]);+ useEffect(() => {+ if (!isInitialFeedLoading) {+ setShowInitialFeedSkeleton(false);+ return;+ }++ const timeoutID = window.setTimeout(+ () => setShowInitialFeedSkeleton(true),+ initialFeedSkeletonDelayMs,+ );+ return () => window.clearTimeout(timeoutID);+ }, [isInitialFeedLoading]);+const loadMoreFeedItems = React.useCallback(async () => {if (!feedNextCursor || isFeedLoadingMore) return;@@ -140,7 +163,11 @@ const Page: React.FC = () => {}}, [feedNextCursor, isFeedLoadingMore]);- if (profileLoadStatus != "ready" || !profile) {+ if (+ profileLoadStatus != "ready" ||+ !profile ||+ (isInitialFeedLoading && !showInitialFeedSkeleton)+ ) {return (<SpaceRouteFallbackbackground={homeBackground}@@ -162,6 +189,7 @@ const Page: React.FC = () => {isFeedLoadingMore={isFeedLoadingMore}localFeedPosts={localFeedPosts}profile={profile}+ showInitialFeedSkeleton={showInitialFeedSkeleton}onAddedFriendToastClose={closeAddedFriendToast}onCreatePost={async (image, caption) => {const spaceId = profile.spaceId;diff --git a/web/apps/space/src/pages/app/messages.tsx b/web/apps/space/src/pages/app/messages.tsxindex 6a9ffd08a2..a195f50c03 100644--- a/web/apps/space/src/pages/app/messages.tsx+++ b/web/apps/space/src/pages/app/messages.tsx@@ -4,6 +4,7 @@ import { useRouter } from "next/router";import React from "react";import { MessagesScreen, messagesBackground } from "screens/MessagesScreen";import {+ createCurrentProfileLink,deleteCurrentMessage,loadCurrentMessageConversations,loadCurrentMessageThread,@@ -215,6 +216,7 @@ const Page: React.FC = () => {/><MessagesScreenconversations={conversations}+ friendsCount={friends.length}isConversationsLoading={isConversationsLoading}isThreadLoading={isThreadLoading}isThreadReadOnly={isThreadReadOnly}@@ -260,6 +262,11 @@ const Page: React.FC = () => {);refreshConversations();}}+ onShareProfileLink={async () => {+ if (!profile.spaceId) throw new Error("Missing space.");+ return (await createCurrentProfileLink(profile.spaceId))+ .url;+ }}onDeleteMessage={async (messageId) => {await deleteCurrentMessage(messageId);setMessages((currentMessages) =>diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsxindex 6d9e751e77..7504da67cd 100644--- a/web/apps/space/src/screens/HomeScreen.tsx+++ b/web/apps/space/src/screens/HomeScreen.tsx@@ -107,6 +107,7 @@ interface HomeScreenProps {onSetPostLiked?: (postId: number, liked: boolean) => Promise<void>;onShareProfileLink?: () => Promise<string>;profile: SetupProfile;+ showInitialFeedSkeleton?: boolean;}interface FeedPhotoDimensions {@@ -939,6 +940,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({onSetPostLiked,onShareProfileLink,profile,+ showInitialFeedSkeleton = false,}) => {const [selectedViewer, setSelectedViewer] =useState<SelectedHomeViewer | null>(null);@@ -964,7 +966,9 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({const hasFeedItems =localFeedPosts.length > 0 || remoteFeedItems.length > 0;const isEmptyFeedLoading = !hasFeedItems && isFeedLoading;- const showFeedCards = hasFeedItems || isEmptyFeedLoading;+ const shouldShowEmptyFeedSkeleton =+ isEmptyFeedLoading && showInitialFeedSkeleton;+ const showFeedCards = hasFeedItems || shouldShowEmptyFeedSkeleton;const showUnreadIndicator = hasUnreadMessages === true;const emptyFeedMessage =friendsCount == 0@@ -981,6 +985,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({const releaseLocalPostObjectUrl = React.useCallback((objectUrl: string) => {localPostObjectUrlsRef.current.delete(objectUrl);}, []);+const openPostPhotoPicker = () => {if (isPostPhotoOpening) return;@@ -1550,9 +1555,9 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({</Box>)}</>- ) : isEmptyFeedLoading ? (+ ) : shouldShowEmptyFeedSkeleton ? (<FeedLoadingSkeletons />- ) : (+ ) : isEmptyFeedLoading ? null : (<Boxsx={{alignItems: "center",@@ -1623,7 +1628,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({}}><ShareIcon />- Share profile+ Invite friends</Box>)}</Box>diff --git a/web/apps/space/src/screens/MessagesScreen.tsx b/web/apps/space/src/screens/MessagesScreen.tsxindex 4144f9a96e..053cc515d1 100644--- a/web/apps/space/src/screens/MessagesScreen.tsx+++ b/web/apps/space/src/screens/MessagesScreen.tsx@@ -12,6 +12,7 @@ import { SpaceLoadingSpinner } from "components/SpaceRouteFallback";import { formatTimeAgo } from "ente-base/date";import React from "react";import type { SetupProfile } from "screens/SetupProfileScreen";+import { ShareIcon } from "screens/ShareProfileLinkScreen";import type { SpaceMessage, SpaceMessageConversation } from "services/space";import { firstNameFrom } from "utils/spaceDisplay";import { clampSpaceMessageText } from "utils/spaceMessageLimits";@@ -49,6 +50,7 @@ const sendSpin = keyframes`interface MessagesScreenProps {conversations: SpaceMessageConversation[];+ friendsCount?: number;isConversationsLoading?: boolean;isThreadLoading?: boolean;isThreadReadOnly?: boolean;@@ -67,6 +69,7 @@ interface MessagesScreenProps {) => Promise<void>;onSendMessage: (spaceId: string, text: string) => Promise<void>;onSetMessageLiked: (messageId: string, liked: boolean) => Promise<void>;+ onShareProfileLink?: () => Promise<string>;newConversationIds?: string[];profile: SetupProfile;selectedFriend?: SpaceMessageConversation["friend"];@@ -992,6 +995,7 @@ const MessageBubble: React.FC<{export const MessagesScreen: React.FC<MessagesScreenProps> = ({conversations,+ friendsCount,isConversationsLoading = false,isThreadLoading = false,isThreadReadOnly = false,@@ -1005,6 +1009,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({onReplyToMessage,onSendMessage,onSetMessageLiked,+ onShareProfileLink,profile,selectedFriend,}) => {@@ -1028,6 +1033,8 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({: "";const isSendStatus = sendPhase != "idle";const isSendButtonActive = canSend || isSendStatus;+ const showInviteEmptyState =+ friendsCount == 0 && Boolean(onShareProfileLink);const messageByID = React.useMemo(() => new Map(messages.map((message) => [message.id, message])),[messages],@@ -1117,6 +1124,23 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({const closeMessageActions = () => setMessageContextMenu(null);+ 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")+ return;+ }+ }++ await copyTextToClipboard(profileLink);+ };+const handleMessageAction = (action: "copy" | "delete" | "like" | "reply",) => {@@ -1905,6 +1929,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({boxSizing: "border-box",display: "flex",flexDirection: "column",+ gap: "22px",inset: 0,justifyContent: "center",pointerEvents: "none",@@ -1923,10 +1948,48 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({fontWeight: 500,lineHeight: "20px",m: 0,+ maxWidth: 260,}}>- No messages yet+ {showInviteEmptyState+ ? "No messages yet. Invite people to start conversations here."+ : "No messages yet."}</Box>+ {showInviteEmptyState && (+ <Box+ component="button"+ type="button"+ onClick={() => void 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",+ pointerEvents: "auto",+ px: "14px",+ whiteSpace: "nowrap",+ "&:focus-visible": {+ outline: `2px solid ${green}`,+ outlineOffset: 2,+ },+ "&:hover": { bgcolor: "#E8E8E8" },+ }}+ >+ <ShareIcon />+ Invite people+ </Box>+ )}</Box>) : (<Box