Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fix Space friend loading, limits, and poke feedback

Anand Baburajan368215318217
diff --git a/server/space/controller/notifications.go b/server/space/controller/notifications.go
index 225ba574f9..a0fff68a1d 100644
--- a/server/space/controller/notifications.go
+++ b/server/space/controller/notifications.go
@@ -139,7 +139,7 @@ func (n *SpaceWebPushSender) OnSpaceMessageSent(actor SpaceActivityActor, recipi
}
func (n *SpaceWebPushSender) OnSpacePokeSent(actor SpaceActivityActor, recipientUserID int64) {
- n.sendAccountActivity(actor, "poked you", "Post something", spaceActivityPokeSent, "/app/post", recipientUserID)
+ n.sendAccountActivity(actor, "poked you", "Post a photo", spaceActivityPokeSent, "/app/post", recipientUserID)
}
func (n *SpaceWebPushSender) OnSpaceMessageLiked(actor SpaceActivityActor, recipientUserID int64) {
diff --git a/server/space/controller/notifications_test.go b/server/space/controller/notifications_test.go
index 8fce441553..9664422921 100644
--- a/server/space/controller/notifications_test.go
+++ b/server/space/controller/notifications_test.go
@@ -367,7 +367,7 @@ func TestSpaceWebPushSenderUsesPokePayloadAndPrunesDeadEndpoint(t *testing.T) {
require.Equal(t, spaceWebPushPayload{
Title: "Ente Space",
Body: "@alice poked you",
- Action: "Post something",
+ Action: "Post a photo",
URL: "/app/post",
}, payload)
var count int
diff --git a/server/space/repo/friends.go b/server/space/repo/friends.go
index a65047a25d..c1a7dbcad4 100644
--- a/server/space/repo/friends.go
+++ b/server/space/repo/friends.go
@@ -56,8 +56,16 @@ func friendCapacityTx(ctx context.Context, tx *sql.Tx, spaceID string) (int, err
var count int
if err := tx.QueryRowContext(ctx, `
SELECT
- (SELECT COUNT(*) FROM space_friend_shares WHERE space_id = $1) +
- (SELECT COUNT(*) FROM space_friend_requests WHERE requester_space_id = $1)
+ (SELECT COUNT(*)
+ FROM space_friend_shares s
+ JOIN spaces friend_space ON friend_space.space_id = s.friend_space_id
+ JOIN users friend_owner ON friend_owner.user_id = friend_space.owner_id AND friend_owner.encrypted_email IS NOT NULL
+ WHERE s.space_id = $1) +
+ (SELECT COUNT(*)
+ FROM space_friend_requests fr
+ JOIN spaces target_space ON target_space.space_id = fr.target_space_id
+ JOIN users target_owner ON target_owner.user_id = target_space.owner_id AND target_owner.encrypted_email IS NOT NULL
+ WHERE fr.requester_space_id = $1)
`, spaceID).Scan(&count); err != nil {
return 0, stacktrace.Propagate(err, "")
}
diff --git a/web/apps/space/src/components/ActionToast.tsx b/web/apps/space/src/components/ActionToast.tsx
index 1376d30381..d83b4a8ae8 100644
--- a/web/apps/space/src/components/ActionToast.tsx
+++ b/web/apps/space/src/components/ActionToast.tsx
@@ -30,6 +30,7 @@ interface SpaceActionToastProps {
icon: React.ReactNode;
message: React.ReactNode;
onClose?: () => void;
+ showCloseButton?: boolean;
zIndex?: number;
}
@@ -41,10 +42,9 @@ export const SpaceActionToast: React.FC<SpaceActionToastProps> = ({
icon,
message,
onClose,
+ showCloseButton = autoDismissAfterMs === undefined,
zIndex = 20,
}) => {
- const showCloseButton = autoDismissAfterMs === undefined;
-
React.useEffect(() => {
if (autoDismissAfterMs === undefined || !onClose) return;
diff --git a/web/apps/space/src/components/PostToast.tsx b/web/apps/space/src/components/PostToast.tsx
index d62f16319b..b44eb23840 100644
--- a/web/apps/space/src/components/PostToast.tsx
+++ b/web/apps/space/src/components/PostToast.tsx
@@ -41,6 +41,7 @@ export const SpacePostToast: React.FC = () => {
}
message={isPosting ? "Posting..." : isFailed ? "Failed" : "Posted"}
onClose={dismissPostPublishToast}
+ showCloseButton={false}
zIndex={1400}
/>
);
diff --git a/web/apps/space/src/pages/app/index.tsx b/web/apps/space/src/pages/app/index.tsx
index 34a42ca5c9..cd1d3fa37a 100644
--- a/web/apps/space/src/pages/app/index.tsx
+++ b/web/apps/space/src/pages/app/index.tsx
@@ -137,21 +137,32 @@ const Page: React.FC = () => {
setLatestPosts(savedHomePosts.latestPosts);
setUnreadPosts(savedHomePosts.unreadPosts);
- setFriends((currentFriends) =>
- currentFriends.length > 0
- ? currentFriends
- : savedHomePosts.latestPosts.map((post) => ({
- avatarKeyVersion: post.avatarKeyVersion,
- avatarObjectID: post.avatarObjectID,
- avatarSize: post.avatarSize,
- avatarUpdatedAt: post.avatarUpdatedAt,
- friendsCount: 0,
- fullName: post.name,
- id: post.friendID,
- spaceId: post.spaceId,
- username: post.username ?? "",
- })),
- );
+ setFriends((currentFriends) => {
+ if (currentFriends.length > 0)
+ return currentFriends;
+
+ return savedHomePosts.friendSpaceIds.map(
+ (friendSpaceId) => {
+ const post =
+ savedHomePosts.latestPosts.find(
+ (post) =>
+ post.spaceId == friendSpaceId,
+ );
+ return {
+ avatarKeyVersion:
+ post?.avatarKeyVersion,
+ avatarObjectID: post?.avatarObjectID,
+ avatarSize: post?.avatarSize,
+ avatarUpdatedAt: post?.avatarUpdatedAt,
+ friendsCount: 0,
+ fullName: post?.name ?? "",
+ id: friendSpaceId,
+ spaceId: friendSpaceId,
+ username: post?.username ?? "",
+ };
+ },
+ );
+ });
setIsLatestPostsLoading(false);
setIsFriendsLoading(false);
}),
diff --git a/web/apps/space/src/screens/MessagesScreen.tsx b/web/apps/space/src/screens/MessagesScreen.tsx
index 2967991453..3ec5c2a90b 100644
--- a/web/apps/space/src/screens/MessagesScreen.tsx
+++ b/web/apps/space/src/screens/MessagesScreen.tsx
@@ -242,7 +242,9 @@ const conversationPreview = (conversation: SpaceMessageConversation) => {
: "Liked a message";
}
if (activity.kind == "poke") {
- return activity.outgoing ? "You poked" : "Poked you";
+ return activity.outgoing
+ ? `You poked ${firstNameFrom(conversation.friend.fullName.trim() || conversation.friend.username)}`
+ : "Poked you";
}
if (text) {
return activity.outgoing ? `You: ${text}` : text;
@@ -779,7 +781,7 @@ const ConversationListItem: React.FC<{
"&:hover": { bgcolor: "#07A820" },
}}
>
- Post something
+ Post a photo
</Box>
)}
{isFriendRequest && (
@@ -1368,6 +1370,7 @@ const isMessageLongPressIgnoredTarget = (target: EventTarget | null) =>
const MessageBubble: React.FC<{
activityPost?: SpaceMessageActivityPost;
+ friendName: string;
groupsWithNext: boolean;
groupsWithPrevious: boolean;
isHighlighted: boolean;
@@ -1384,6 +1387,7 @@ const MessageBubble: React.FC<{
profile: SetupProfile;
}> = ({
activityPost,
+ friendName,
groupsWithNext,
groupsWithPrevious,
isHighlighted,
@@ -1398,7 +1402,8 @@ const MessageBubble: React.FC<{
const isOwn = message.sender.spaceId == ownSpaceID;
const isUnavailable = Boolean(message.isUnavailable);
const isPoke = !isUnavailable && message.kind == "poke";
- const pokeText = isOwn ? "You poked" : "Poked you";
+ const pokeName = firstNameFrom(friendName);
+ const pokeText = isOwn ? `You poked ${pokeName}` : `${pokeName} poked you`;
const bubbleBorderRadius = isOwn
? `20px ${groupsWithPrevious ? "6px" : "20px"} ${groupsWithNext ? "6px" : "20px"} 20px`
: `${groupsWithPrevious ? "6px" : "20px"} 20px 20px ${groupsWithNext ? "6px" : "20px"}`;
@@ -2468,6 +2473,9 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
]
: undefined
}
+ friendName={
+ selectedName
+ }
groupsWithNext={
groupsWithNext
}