π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Fix stale space friend preview copy
Anand Baburajan65ddfff69c0e
diff --git a/web/apps/space/src/pages/app/notifications.tsx b/web/apps/space/src/pages/app/notifications.tsxindex 24c03b6e2c..b35cee559a 100644--- a/web/apps/space/src/pages/app/notifications.tsx+++ b/web/apps/space/src/pages/app/notifications.tsx@@ -27,6 +27,7 @@ const Page: React.FC = () => {>([]);const [isConversationsLoading, setIsConversationsLoading] =React.useState(true);+ const [isFriendsLoaded, setIsFriendsLoaded] = React.useState(false);const [isThreadLoading, setIsThreadLoading] = React.useState(false);const [messages, setMessages] = React.useState<SpaceMessage[]>([]);const [selectedFriend, setSelectedFriend] = React.useState<@@ -108,8 +109,12 @@ const Page: React.FC = () => {React.useEffect(() => {if (!profile?.spaceId) return;+ setIsFriendsLoaded(false);void loadCurrentSpaceFriends(profile.spaceId)- .then(setFriends)+ .then((nextFriends) => {+ setFriends(nextFriends);+ setIsFriendsLoaded(true);+ }).catch((error: unknown) =>console.error("Failed to load space friends", error),);@@ -151,7 +156,9 @@ const Page: React.FC = () => {<SpacePageMeta themeColor={messagesBackground} /><MessagesScreenconversations={conversations}+ friends={friends}isConversationsLoading={isConversationsLoading}+ isFriendsLoaded={isFriendsLoaded}isThreadLoading={isThreadLoading}isThreadReadOnly={isThreadReadOnly}messages={messages}diff --git a/web/apps/space/src/screens/MessagesScreen.tsx b/web/apps/space/src/screens/MessagesScreen.tsxindex 2600b973c9..c81e35cb08 100644--- a/web/apps/space/src/screens/MessagesScreen.tsx+++ b/web/apps/space/src/screens/MessagesScreen.tsx@@ -9,6 +9,7 @@ import { HugeiconsIcon } from "@hugeicons/react";import { Box, Menu, MenuItem, Tooltip } from "@mui/material";import { keyframes } from "@mui/material/styles";import { SpaceLoadingSpinner } from "components/SpaceRouteFallback";+import type { FriendProfile } from "data/friends";import { formatTimeAgo } from "ente-base/date";import React from "react";import type { SetupProfile } from "screens/SetupProfileScreen";@@ -49,7 +50,9 @@ const sendSpin = keyframes`interface MessagesScreenProps {conversations: SpaceMessageConversation[];+ friends: FriendProfile[];isConversationsLoading?: boolean;+ isFriendsLoaded?: boolean;isThreadLoading?: boolean;isThreadReadOnly?: boolean;messages: SpaceMessage[];@@ -195,13 +198,41 @@ const messageLikeTooltipLabel = (return likerNames.filter(Boolean).join(" and ") || "Liked";};+const isCurrentFriend = (+ conversationFriend: SpaceMessageConversation["friend"],+ friends: FriendProfile[],+) => {+ const conversationSpaceId =+ conversationFriend.spaceId ?? conversationFriend.id;+ const conversationSpaceSlug = conversationFriend.spaceSlug;+ const conversationUsername = conversationFriend.username;+ return friends.some((friend) => {+ const friendSpaceId = friend.spaceId ?? friend.id;+ return (+ friendSpaceId == conversationSpaceId ||+ (conversationSpaceSlug &&+ friend.spaceSlug == conversationSpaceSlug) ||+ friend.username == conversationUsername+ );+ });+};+const conversationPreview = (conversation: SpaceMessageConversation,profile: SetupProfile,+ currentlyFriends?: boolean,) => {const activity = conversation.latestActivity;- if (activity.type == "friend_add") return "Added you as a friend";- if (activity.type == "friend_remove") return "Removed you as a friend";+ if (activity.type == "friend_add") {+ return currentlyFriends === false+ ? "No longer friends"+ : "Added you as a friend";+ }+ if (activity.type == "friend_remove") {+ return currentlyFriends === true+ ? "Friends again"+ : "Removed you as a friend";+ }if (activity.type == "post_like") return "Liked your post";if (activity.type == "post_reply") {return "Replied";@@ -245,8 +276,9 @@ const quotedConversationActivityPreview = (const ConversationPreviewLine: React.FC<{conversation: SpaceMessageConversation;+ currentlyFriends?: boolean;profile: SetupProfile;-}> = ({ conversation, profile }) => {+}> = ({ conversation, currentlyFriends, profile }) => {const activity = conversation.latestActivity;const quotedPreview = quotedConversationActivityPreview(activity);const previewLineSx = {@@ -264,7 +296,7 @@ const ConversationPreviewLine: React.FC<{if (!quotedPreview) {return (<Box sx={previewLineSx}>- {conversationPreview(conversation, profile)}+ {conversationPreview(conversation, profile, currentlyFriends)}</Box>);}@@ -801,7 +833,9 @@ const MessageBubble: React.FC<{export const MessagesScreen: React.FC<MessagesScreenProps> = ({conversations,+ friends,isConversationsLoading = false,+ isFriendsLoaded = false,isThreadLoading = false,isThreadReadOnly = false,messages,@@ -1702,6 +1736,10 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({const name =conversation.friend.fullName.trim() ||conversation.friend.username;+ const currentlyFriends = isCurrentFriend(+ conversation.friend,+ friends,+ );const timestampLabel = formatTimeAgo(microsForTimestamp(conversation.latestActivity@@ -1842,6 +1880,11 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({conversation={conversation}+ currentlyFriends={+ isFriendsLoaded+ ? currentlyFriends+ : undefined+ }profile={profile}/></Box>