π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Show own post likes in Space viewer
Anand Baburajan93e2dc8f93ab
diff --git a/web/apps/space/src/components/SpaceFileViewer.tsx b/web/apps/space/src/components/SpaceFileViewer.tsxindex 87a8f8ff0d..5845b81c81 100644--- a/web/apps/space/src/components/SpaceFileViewer.tsx+++ b/web/apps/space/src/components/SpaceFileViewer.tsx@@ -21,8 +21,10 @@ import {spacePostLikePopDurationMs,spacePostLikePopTiming,} from "components/SpacePostLikeAnimation";+import { SpacePostLikersDialog } from "components/SpacePostLikersDialog";import type PhotoSwipe from "photoswipe";import React from "react";+import type { SpacePostLiker, SpacePostLikersLoader } from "services/space";import { spaceTouchTargetSize } from "styles/touchTargets";import { firstNameFrom, formatSpaceDate } from "utils/spaceDisplay";import { clampSpaceMessageText } from "utils/spaceMessageLimits";@@ -77,7 +79,11 @@ const photoPreviewSkeletonShimmer = keyframes`}`;-export type SpaceViewerPostActionMode = "draft-post" | "hidden" | "like-only";+export type SpaceViewerPostActionMode =+ | "draft-post"+ | "hidden"+ | "like-only"+ | "own-post-likes";export interface SpaceViewerDraftPostEdit {cropArea?: SpaceImageCropArea;@@ -88,15 +94,17 @@ export interface SpaceViewerDraftPostEdit {interface SpaceViewerPostActionConfig {showLikeButton: boolean;+ showLikeCountButton: boolean;}const spaceViewerPostActionConfigs: Record<SpaceViewerPostActionMode,SpaceViewerPostActionConfig> = {- "draft-post": { showLikeButton: false },- hidden: { showLikeButton: false },- "like-only": { showLikeButton: true },+ "draft-post": { showLikeButton: false, showLikeCountButton: false },+ hidden: { showLikeButton: false, showLikeCountButton: false },+ "like-only": { showLikeButton: true, showLikeCountButton: false },+ "own-post-likes": { showLikeButton: false, showLikeCountButton: true },};export interface SpaceViewerPhoto {@@ -106,6 +114,7 @@ export interface SpaceViewerPhoto {friendID?: string;height?: number;imageUrl: string;+ likeCount?: number;name: string;postId?: number;timestampMs: number;@@ -121,6 +130,7 @@ interface SpaceFileViewerProps {onDeletePost?: () => Promise<void> | void;onDraftPostPublished?: () => void;onAddFriendForPostAction?: () => void;+ onLoadPostLikers?: SpacePostLikersLoader;onOpenProfile?: () => void;onPublishDraftPost?: (caption: string,@@ -265,6 +275,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({onDeletePost,onDraftPostPublished,onAddFriendForPostAction,+ onLoadPostLikers,onOpenProfile,onPublishDraftPost,onReplyToPost,@@ -279,8 +290,10 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({}) => {const activePostActionMode = postActionMode;const isDraftPost = activePostActionMode == "draft-post";- const { showLikeButton: showPhotoLikeButton } =- spaceViewerPostActionConfigs[activePostActionMode];+ const {+ showLikeButton: showPhotoLikeButton,+ showLikeCountButton: showPhotoLikeCountButton,+ } = spaceViewerPostActionConfigs[activePostActionMode];const canDeletePost = !isDraftPost && Boolean(onDeletePost);const viewerPhotos = photos && photos.length > 0 ? photos : [photo];const activePhotoIndex = Math.min(@@ -338,6 +351,13 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({const [deleteActionPhase, setDeleteActionPhase] =React.useState<SpaceActionPhase | null>(null);const [isDeleteExit, setIsDeleteExit] = React.useState(false);+ const [postLikersOpen, setPostLikersOpen] = React.useState(false);+ const [postLikersLoading, setPostLikersLoading] = React.useState(false);+ const [postLikersError, setPostLikersError] = React.useState<string | null>(+ null,+ );+ const [postLikers, setPostLikers] = React.useState<SpacePostLiker[]>([]);+ const postLikersRequestIDRef = React.useRef(0);const actionsMenuID = "space-viewer-actions-menu";const actionsButtonID = "space-viewer-actions-button";const isActionsOpen = Boolean(actionsAnchor);@@ -378,6 +398,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({isSwipeBlockedRef.current =isActionsOpen ||(canDeletePost && deleteSheetOpen) ||+ postLikersOpen ||isDeleteExit ||isDraftPost ||isDraftPostPreviewPending;@@ -405,6 +426,43 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({);};+ const openPostLikers = () => {+ if (!activePhoto.postId || !onLoadPostLikers) return;++ const requestID = postLikersRequestIDRef.current + 1;+ postLikersRequestIDRef.current = requestID;+ setPostLikersOpen(true);+ setPostLikersLoading(true);+ setPostLikersError(null);++ void onLoadPostLikers(activePhoto.postId)+ .then((likers) => {+ if (postLikersRequestIDRef.current == requestID) {+ setPostLikers(likers);+ }+ })+ .catch((error: unknown) => {+ console.error("Failed to load post likers", error);+ if (postLikersRequestIDRef.current == requestID) {+ setPostLikers([]);+ setPostLikersError(+ "Couldn't load likes. Please try again.",+ );+ }+ })+ .finally(() => {+ if (postLikersRequestIDRef.current == requestID) {+ setPostLikersLoading(false);+ }+ });+ };++ const closePostLikers = () => {+ postLikersRequestIDRef.current += 1;+ setPostLikersOpen(false);+ setPostLikersLoading(false);+ };+const closeActions = () => setActionsAnchor(null);const requestDeletePost = () => {@@ -611,7 +669,12 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({]);React.useEffect(() => {+ postLikersRequestIDRef.current += 1;setPhotoLikePopID(0);+ setPostLikers([]);+ setPostLikersError(null);+ setPostLikersLoading(false);+ setPostLikersOpen(false);}, [activePhoto.imageUrl, activePhoto.postId]);React.useEffect(() => {@@ -830,7 +893,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({React.useEffect(() => {const closeOnEscape = (event: KeyboardEvent) => {- if (deleteSheetOpen) return;+ if (deleteSheetOpen || postLikersOpen) return;if (event.key != "Escape") return;onCloseRef.current();@@ -838,7 +901,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({window.addEventListener("keydown", closeOnEscape);return () => window.removeEventListener("keydown", closeOnEscape);- }, [deleteSheetOpen]);+ }, [deleteSheetOpen, postLikersOpen]);return (<Box@@ -1661,6 +1724,96 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({</Box></Box>)}+ {showPhotoLikeCountButton && (+ <Box+ data-space-viewer-bottom="true"+ sx={{+ bottom: "max(24px, calc(env(safe-area-inset-bottom) + 16px))",+ position: "fixed",+ right: "16px",+ zIndex: 2,+ }}+ >+ <Box+ component="button"+ type="button"+ aria-label={`View ${activePhoto.likeCount ?? 0} likes`}+ disabled={!activePhoto.postId || !onLoadPostLikers}+ onClick={openPostLikers}+ sx={{+ alignItems: "center",+ bgcolor: "transparent",+ border: 0,+ borderRadius: "8px",+ color: textBase,+ cursor:+ activePhoto.postId && onLoadPostLikers+ ? "pointer"+ : "default",+ display: "inline-flex",+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 14,+ fontWeight: 750,+ height: 48,+ justifyContent: "center",+ lineHeight: "20px",+ position: "relative",+ width: 48,+ p: 0,+ py: 0,+ "&:disabled": { opacity: 1 },+ "&:focus-visible": {+ outline: `2px solid ${green}`,+ outlineOffset: 2,+ },+ "&:hover": {+ bgcolor: "transparent",+ },+ }}+ >+ <Box+ component="span"+ sx={{+ alignItems: "center",+ display: "flex",+ lineHeight: 0,+ }}+ >+ <HugeiconsIcon+ fill="none"+ icon={FavouriteIcon}+ primaryColor="currentColor"+ size={30}+ strokeWidth={1.8}+ />+ </Box>+ <Box+ component="span"+ sx={{+ alignItems: "center",+ bgcolor: textBase,+ border: "2px solid #000000",+ borderRadius: "999px",+ color: "#111111",+ display: "flex",+ fontFamily:+ '"Inter Variable", Inter, sans-serif',+ fontSize: 10,+ fontWeight: 800,+ height: 18,+ justifyContent: "center",+ lineHeight: "11px",+ width: 18,+ position: "absolute",+ right: 2,+ top: 8,+ }}+ >+ {activePhoto.likeCount ?? 0}+ </Box>+ </Box>+ </Box>+ )}{canDeletePost && (<ConfirmationActionSheetappearance="dark"@@ -1675,6 +1828,13 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({onExited={handleDeleteSheetExited}/>)}+ <SpacePostLikersDialog+ errorMessage={postLikersError}+ likers={postLikers}+ loading={postLikersLoading}+ open={postLikersOpen}+ onClose={closePostLikers}+ /></Box>);};diff --git a/web/apps/space/src/components/SpacePostLikersDialog.tsx b/web/apps/space/src/components/SpacePostLikersDialog.tsxnew file mode 100644index 0000000000..997f1049f2--- /dev/null+++ b/web/apps/space/src/components/SpacePostLikersDialog.tsx@@ -0,0 +1,213 @@+import { Box, Dialog, useMediaQuery } from "@mui/material";+import { SpaceBottomSheetTransition } from "components/SpaceBottomSheetTransition";+import React from "react";+import type { SpacePostLiker } from "services/space";++const textBase = "#F4F4F4";+const textSecondary = "#A6A6A6";+const dangerColor = "#F63A3A";+const sheetBackground = "#1E1E1E";+const avatarBackground = "#333333";++interface SpacePostLikersDialogProps {+ errorMessage?: string | null;+ likers: SpacePostLiker[];+ loading: boolean;+ open: boolean;+ onClose: () => void;+}++export const SpacePostLikersDialog: React.FC<SpacePostLikersDialogProps> = ({+ errorMessage,+ likers,+ loading,+ open,+ onClose,+}) => {+ const isBottomSheet = useMediaQuery("(max-width: 599px)");++ return (+ <Dialog+ open={open}+ onClose={onClose}+ maxWidth={false}+ aria-label="Likes"+ slots={+ isBottomSheet+ ? { transition: SpaceBottomSheetTransition }+ : undefined+ }+ sx={{+ zIndex: 1500,+ "& .MuiBackdrop-root": {+ backgroundColor: "rgba(0, 0, 0, 0.86) !important",+ },+ "& .MuiDialog-container": { backgroundColor: "transparent" },+ "& .MuiPaper-root": {+ backgroundColor: `${sheetBackground} !important`,+ },+ }}+ slotProps={{+ backdrop: { sx: { backgroundColor: "rgba(0, 0, 0, 0.86)" } },+ paper: {+ sx: {+ bgcolor: sheetBackground,+ backgroundColor: sheetBackground,+ borderRadius: "28px 28px 0 0",+ bottom: 0,+ boxShadow: "none",+ boxSizing: "border-box",+ left: 0,+ m: 0,+ maxWidth: "none",+ p: "24px 20px calc(18px + env(safe-area-inset-bottom))",+ position: "fixed",+ width: "100vw",+ "@media (min-width: 600px)": {+ borderRadius: "20px",+ bottom: "auto",+ boxShadow: "0 18px 48px rgba(0, 0, 0, 0.18)",+ left: "50%",+ maxWidth: 342,+ p: "16px 20px 14px",+ top: "50%",+ transform: "translate(-50%, -50%)",+ width: 342,+ },+ },+ },+ }}+ >+ <Box sx={{ width: "100%" }}>+ <Box sx={{ maxHeight: "min(420px, 62vh)", overflowY: "auto" }}>+ {loading ? null : errorMessage ? (+ <Box+ role="alert"+ sx={{+ color: dangerColor,+ fontFamily:+ '"Inter Variable", Inter, sans-serif',+ fontSize: 13,+ fontWeight: 650,+ lineHeight: "18px",+ py: "20px",+ textAlign: "center",+ }}+ >+ {errorMessage}+ </Box>+ ) : likers.length == 0 ? (+ <Box+ sx={{+ color: textSecondary,+ fontFamily:+ '"Inter Variable", Inter, sans-serif',+ fontSize: 14,+ fontWeight: 600,+ lineHeight: "20px",+ py: "20px",+ textAlign: "center",+ }}+ >+ No likes yet+ </Box>+ ) : (+ <Box+ component="ul"+ sx={{+ display: "flex",+ flexDirection: "column",+ gap: "8px",+ listStyle: "none",+ m: 0,+ p: 0,+ }}+ >+ {likers.map((liker) => (+ <SpacePostLikerRow+ key={`${liker.profile.id}:${liker.createdAtMs}`}+ liker={liker}+ />+ ))}+ </Box>+ )}+ </Box>+ </Box>+ </Dialog>+ );+};++const SpacePostLikerRow: React.FC<{ liker: SpacePostLiker }> = ({ liker }) => {+ const profile = liker.profile;+ const displayName =+ profile.fullName.trim() || profile.username.trim() || "Someone";++ return (+ <Box+ component="li"+ sx={{+ alignItems: "center",+ display: "grid",+ gap: "8px",+ gridTemplateColumns: "32px minmax(0, 1fr) 24px",+ minHeight: 42,+ py: "4px",+ }}+ >+ <Box+ sx={{+ bgcolor: avatarBackground,+ borderRadius: "50%",+ height: 32,+ overflow: "hidden",+ width: 32,+ }}+ >+ {profile.avatarUrl ? (+ <Box+ component="img"+ alt=""+ src={profile.avatarUrl}+ sx={{+ display: "block",+ height: "100%",+ objectFit: "cover",+ objectPosition: "center",+ width: "100%",+ }}+ />+ ) : null}+ </Box>+ <Box+ sx={{+ color: textBase,+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 15,+ fontWeight: 650,+ lineHeight: "20px",+ minWidth: 0,+ overflow: "hidden",+ textOverflow: "ellipsis",+ whiteSpace: "nowrap",+ }}+ >+ {displayName}+ </Box>+ <Box+ aria-hidden+ className="green-bg"+ component="span"+ sx={filledHeartIconSx}+ />+ </Box>+ );+};++const filledHeartIconSx = {+ display: "block",+ height: 18,+ justifySelf: "center",+ mask: `url("data:image/svg+xml,%3Csvg width='16' height='14' viewBox='0 0 16 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6.63749 12.3742C4.66259 10.885 0.75 7.4804 0.75 4.41664C0.75 2.39161 2.22368 0.75 4.25 0.75C5.3 0.75 6.35 1.10294 7.75 2.51469C9.15 1.10294 10.2 0.75 11.25 0.75C13.2763 0.75 14.75 2.39161 14.75 4.41664C14.75 7.4804 10.8374 10.885 8.86251 12.3742C8.19793 12.8753 7.30207 12.8753 6.63749 12.3742Z' fill='black'/%3E%3C/svg%3E") center / contain no-repeat`,+ WebkitMask: `url("data:image/svg+xml,%3Csvg width='16' height='14' viewBox='0 0 16 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6.63749 12.3742C4.66259 10.885 0.75 7.4804 0.75 4.41664C0.75 2.39161 2.22368 0.75 4.25 0.75C5.3 0.75 6.35 1.10294 7.75 2.51469C9.15 1.10294 10.2 0.75 11.25 0.75C13.2763 0.75 14.75 2.39161 14.75 4.41664C14.75 7.4804 10.8374 10.885 8.86251 12.3742C8.19793 12.8753 7.30207 12.8753 6.63749 12.3742Z' fill='black'/%3E%3C/svg%3E") center / contain no-repeat`,+ width: 20,+};diff --git a/web/apps/space/src/pages/app/index.tsx b/web/apps/space/src/pages/app/index.tsxindex fb3f50ce43..ea5bd427b5 100644--- a/web/apps/space/src/pages/app/index.tsx+++ b/web/apps/space/src/pages/app/index.tsx@@ -8,6 +8,7 @@ import {createCurrentProfileLink,deleteCurrentPost,loadCurrentFeedPage,+ loadCurrentPostLikers,loadCurrentSpaceFriends,loadCurrentSpacePostAssetURL,loadCurrentSpacePostAvatarURL,@@ -296,6 +297,7 @@ const Page: React.FC = () => {onLoadMoreFeedItems={loadMoreFeedItems}onLoadPostAvatar={loadCurrentSpacePostAvatarURL}onLoadPostImage={loadCurrentSpacePostAssetURL}+ onLoadPostLikers={loadCurrentPostLikers}onOpenMessages={() => void router.push(spaceRoutes.messages)}onOpenNotifications={() =>void router.push(spaceRoutes.notifications)diff --git a/web/apps/space/src/pages/app/posts/[spaceId]/[postId].tsx b/web/apps/space/src/pages/app/posts/[spaceId]/[postId].tsxindex c4fa200bd0..d67c5df108 100644--- a/web/apps/space/src/pages/app/posts/[spaceId]/[postId].tsx+++ b/web/apps/space/src/pages/app/posts/[spaceId]/[postId].tsx@@ -4,6 +4,7 @@ import { SpaceRouteFallback } from "components/SpaceRouteFallback";import { useRouter } from "next/router";import React from "react";import {+ loadCurrentPostLikers,loadCurrentSpacePost,replyToCurrentPost,setCurrentPostLiked,@@ -50,6 +51,7 @@ const viewerPhotoFromPost = (post: SpacePost) => ({friendID: post.friendID,height: post.height,imageUrl: post.imageUrl ?? "",+ likeCount: post.likeCount,name: post.name,postId: post.postId,timestampMs: post.timestampMs,@@ -153,8 +155,9 @@ const Page: React.FC = () => {/><SpaceFileViewerphoto={viewerPhotoFromPost(post)}- postActionMode={isOwnPost ? "hidden" : "like-only"}+ postActionMode={isOwnPost ? "own-post-likes" : "like-only"}onClose={closePost}+ onLoadPostLikers={loadCurrentPostLikers}onOpenProfile={() => void router.push(ownerProfileRoute())}onReplyToPost={isOwnPost ? undefined : replyToCurrentPost}onSetPostLiked={setCurrentPostLiked}diff --git a/web/apps/space/src/pages/app/profile.tsx b/web/apps/space/src/pages/app/profile.tsxindex e06c6cfece..dc1da0660b 100644--- a/web/apps/space/src/pages/app/profile.tsx+++ b/web/apps/space/src/pages/app/profile.tsx@@ -6,6 +6,7 @@ import { ProfileScreen, profileBackground } from "screens/ProfileScreen";import {createCurrentPhotoPost,deleteCurrentPost,+ loadCurrentPostLikers,loadCurrentSpaceFriendsCount,loadCurrentSpacePostAssetURL,loadCurrentSpaceProfilePostsPage,@@ -189,6 +190,7 @@ const Page: React.FC = () => {}onOpenSettings={() => void router.push(spaceRoutes.settings)}onLoadPostImage={loadCurrentSpacePostAssetURL}+ onLoadPostLikers={loadCurrentPostLikers}onSetPostLiked={setCurrentPostLiked}/></>diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsxindex a868930d63..5167fa7f72 100644--- a/web/apps/space/src/screens/HomeScreen.tsx+++ b/web/apps/space/src/screens/HomeScreen.tsx@@ -31,6 +31,7 @@ import type {SpacePost,SpacePostAssetURLLoader,SpacePostAvatarURLLoader,+ SpacePostLikersLoader,} from "services/space";import type { LocalSpaceFeedPost } from "state/spaceAppState";import { spaceTouchTargetSize } from "styles/touchTargets";@@ -124,6 +125,7 @@ interface HomeScreenProps {onLoadMoreFeedItems?: () => Promise<void> | void;onLoadPostAvatar?: SpacePostAvatarURLLoader;onLoadPostImage?: SpacePostAssetURLLoader;+ onLoadPostLikers?: SpacePostLikersLoader;onOpenFriend?: (friendID: string) => void;onOpenMessages?: () => void;onOpenNotifications?: () => void;@@ -178,6 +180,7 @@ interface FeedItemProps {friendID: string;imageUrl?: string;isOwnPost: boolean;+ likeCount?: number;name: string;onLoadAvatar?: () => Promise<string | null | undefined>;onLoadImage?: () => Promise<string | undefined>;@@ -621,6 +624,7 @@ const FeedItem: React.FC<FeedItemProps> = ({friendID,imageUrl,isOwnPost,+ likeCount = 0,name,onLoadAvatar,onLoadImage,@@ -711,6 +715,7 @@ const FeedItem: React.FC<FeedItemProps> = ({friendID,height: photoDimensions.height,imageUrl: displayImageUrl,+ likeCount,name,postId,timestampMs,@@ -1297,6 +1302,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({onLoadMoreFeedItems,onLoadPostAvatar,onLoadPostImage,+ onLoadPostLikers,onOpenFriend,onOpenMessages,onOpenNotifications,@@ -1384,7 +1390,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({setSelectedViewer({focusReplyOnOpen: isOwnPost ? false : focusReplyOnOpen,photo,- postActionMode: isOwnPost ? "hidden" : "like-only",+ postActionMode: isOwnPost ? "own-post-likes" : "like-only",});};const closeSelectedPhoto = () => {@@ -1511,6 +1517,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({isOwnPost={Boolean(profileSpaceId) && item.spaceId == profileSpaceId}+ likeCount={item.likeCount}name={item.name}onLoadAvatar={avatarUrl === undefined@@ -2233,6 +2240,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({onDraftPostPublished={() =>setFeedScrollRequest((request) => request + 1)}+ onLoadPostLikers={onLoadPostLikers}onSetPostLiked={onSetPostLiked}/>)}diff --git a/web/apps/space/src/screens/ProfileScreen.tsx b/web/apps/space/src/screens/ProfileScreen.tsxindex d6b5485e7f..9616fc7904 100644--- a/web/apps/space/src/screens/ProfileScreen.tsx+++ b/web/apps/space/src/screens/ProfileScreen.tsx@@ -17,7 +17,7 @@ import { EnteLogo } from "ente-base/components/EnteLogo";import { useBrowserBackClose } from "hooks/useBrowserBackClose";import React, { useState } from "react";import type { SetupProfile } from "screens/SetupProfileScreen";-import type { SpacePostAsset } from "services/space";+import type { SpacePostAsset, SpacePostLikersLoader } from "services/space";import { spaceTouchTargetSize } from "styles/touchTargets";import { createLoadedLocalPostPhoto } from "utils/localPostPhoto";import { firstNameFrom } from "utils/spaceDisplay";@@ -66,6 +66,7 @@ export interface ProfilePostItem {id: string;imageAsset?: SpacePostAsset;imageUrl?: string;+ likeCount?: number;name?: string;postId?: number;timestampMs: number;@@ -402,6 +403,7 @@ interface ProfileScreenProps {onOpenProfilePhoto?: () => void;onOpenSettings?: () => void;onLoadPostImage?: (asset: SpacePostAsset) => Promise<string>;+ onLoadPostLikers?: SpacePostLikersLoader;onReplyToPost?: (postId: number, text: string) => Promise<void>;onSetPostLiked?: (postId: number, liked: boolean) => Promise<void>;postGroups?: ProfilePostGroup[];@@ -424,6 +426,7 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({onOpenProfilePhoto,onOpenSettings,onLoadPostImage,+ onLoadPostLikers,onReplyToPost,onSetPostLiked,postGroups = [],@@ -488,7 +491,7 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({const selectedPostActionMode: SpaceViewerPostActionMode = isPublicProfile? "like-only": isOwnerProfile- ? "hidden"+ ? "own-post-likes": "like-only";const revokeLocalPostObjectUrls = React.useCallback(() => {@@ -603,6 +606,7 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({caption: item.caption,height: dimensions.height,imageUrl,+ likeCount: item.likeCount ?? 0,name: displayName,postId: item.postId,timestampMs: item.timestampMs,@@ -632,6 +636,7 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({name: displayName,postId: item.postId,timestampMs: item.timestampMs,+ likeCount: item.likeCount ?? 0,viewerLiked: item.viewerLiked,width: dimensions.width,};@@ -1616,6 +1621,7 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({onAddFriendForPostAction={isPublicProfile ? onAddFriend : undefined}+ onLoadPostLikers={onLoadPostLikers}onOpenProfile={closeSelectedPost}onReplyToPost={isFriendProfile ? onReplyToPost : undefineddiff --git a/web/apps/space/src/services/space.ts b/web/apps/space/src/services/space.tsindex 5ad921b01e..90f699b625 100644--- a/web/apps/space/src/services/space.ts+++ b/web/apps/space/src/services/space.ts@@ -12,6 +12,7 @@ import {import { normalizeSpaceMessageText } from "utils/spaceMessageLimits";const currentFeedPageSize = 10;+const postLikersPageSize = 100;interface SpaceAvatar {objectKey: string;@@ -63,6 +64,7 @@ interface SpacePostResponse {createdAt: string;encryptedPostKey: string;keyVersion: number;+ likes?: number;objects?: SpacePostObject[];postId: number;viewerLiked: boolean;@@ -75,6 +77,16 @@ interface SpacePostPageResponse {nextCursor?: string;}+interface SpacePostLikerResponse {+ actor: SpaceActor;+ createdAt: string;+}++interface SpacePostLikersPageResponse {+ likers?: SpacePostLikerResponse[];+ nextCursor?: string;+}+type SpaceMessageConversationActivityType =| "message"| "message_like"@@ -178,6 +190,7 @@ interface SpacePostBase {caption?: string;friendID: string;height?: number;+ likeCount: number;name: string;postId: number;timestampMs: number;@@ -215,6 +228,15 @@ export interface SpaceProfilePostPage {nextCursor?: string;}+export interface SpacePostLiker {+ createdAtMs: number;+ profile: FriendProfile;+}++export type SpacePostLikersLoader = (+ postId: number,+) => Promise<SpacePostLiker[]>;+export type SpacePostAssetURLLoader = (asset: SpacePostAsset,) => Promise<string>;@@ -693,6 +715,7 @@ const postFromAccountPost = async (height: object.height,imageAsset: postAssetFrom(post, object),imageUrl,+ likeCount: post.likes ?? 0,name: author.fullName || author.username,postId: post.postId,timestampMs: timestampMsFromSpaceDate(post.createdAt),@@ -718,6 +741,7 @@ const profilePostFromPost = (friendID: author.id,height: object.height,imageAsset: postAssetFrom(post, object),+ likeCount: post.likes ?? 0,name: author.fullName || author.username,postId: post.postId,timestampMs: timestampMsFromSpaceDate(post.createdAt),@@ -751,6 +775,19 @@ const profilePostPageFromPage = (nextCursor: page.nextCursor || undefined,});+const postLikerFromResponse = async (+ ctx: SpaceAccountCtxHandle,+ liker: SpacePostLikerResponse,+): Promise<SpacePostLiker> => {+ const profile = actorProfile(liker.actor);+ profile.avatarUrl = await accountAvatarURL(+ ctx,+ liker.actor.spaceId,+ liker.actor.avatar,+ );+ return { createdAtMs: timestampMsFromSpaceDate(liker.createdAt), profile };+};+const messageQuoteFromSpaceQuote = async (ctx: SpaceAccountCtxHandle,quote: SpaceMessageQuoteResponse | undefined,@@ -1186,6 +1223,34 @@ export const setCurrentPostLiked = async (postId: number, liked: boolean) => {}};+export const loadCurrentPostLikers = async (+ postId: number,+): Promise<SpacePostLiker[]> => {+ const ctx = await ensureCurrentSpaceContext();+ try {+ const likers: SpacePostLiker[] = [];+ let cursor: string | undefined;+ do {+ const page = (await ctx.list_post_likers(+ BigInt(postId),+ cursor ?? null,+ postLikersPageSize,+ )) as SpacePostLikersPageResponse;+ likers.push(+ ...(await Promise.all(+ (page.likers ?? []).map((liker) =>+ postLikerFromResponse(ctx, liker),+ ),+ )),+ );+ cursor = page.nextCursor || undefined;+ } while (cursor);+ return likers;+ } finally {+ releaseCurrentSpaceContext(ctx);+ }+};+export const replyToCurrentPost = async (postId: number, text: string) => {const messageText = normalizeSpaceMessageText(text);const ctx = await ensureCurrentSpaceContext();diff --git a/web/apps/space/src/utils/spacePostDisplay.ts b/web/apps/space/src/utils/spacePostDisplay.tsindex 0fdcd035e6..1119073115 100644--- a/web/apps/space/src/utils/spacePostDisplay.ts+++ b/web/apps/space/src/utils/spacePostDisplay.ts@@ -29,6 +29,7 @@ export const profilePostGroupsFromPosts = (id: String(post.postId),imageAsset: post.imageAsset,imageUrl: post.imageUrl,+ likeCount: post.likeCount,name: post.name,postId: post.postId,timestampMs: post.timestampMs,