Skip to content

armgit / ente

Public Imported from GitHub
0

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

Remove own post like counts

Anand Baburajan4ccb2b3d0c6a
diff --git a/web/apps/space/src/components/SpaceFileViewer.tsx b/web/apps/space/src/components/SpaceFileViewer.tsx
index d69d27f5b3..1dca693b3a 100644
--- a/web/apps/space/src/components/SpaceFileViewer.tsx
+++ b/web/apps/space/src/components/SpaceFileViewer.tsx
@@ -11,21 +11,19 @@ import { HugeiconsIcon } from "@hugeicons/react";
import { Box, Menu, MenuItem } from "@mui/material";
import { keyframes } from "@mui/material/styles";
import { ConfirmationActionSheet } from "components/ConfirmationActionSheet";
-import { SpaceAvatarImage } from "components/SpaceAvatarImage";
import {
spaceActionDoneDurationMs,
type SpaceActionPhase,
} from "components/SpaceActionFeedback";
+import { SpaceAvatarImage } from "components/SpaceAvatarImage";
import {
spacePostLikeButtonPop,
spacePostLikeHeartPop,
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";
@@ -33,7 +31,6 @@ import type { SpaceImageCropArea } from "utils/spacePostImage";
const green = "#08C225";
const textBase = "#F4F4F4";
-const viewerLikeCountText = "#D8D8D8";
const textSecondary = "#A6A6A6";
const textTertiary = "rgba(244, 244, 244, 0.52)";
const viewerBackground = "#000000";
@@ -80,11 +77,7 @@ const photoPreviewSkeletonShimmer = keyframes`
}
`;
-export type SpaceViewerPostActionMode =
- | "draft-post"
- | "hidden"
- | "like-only"
- | "own-post-likes";
+export type SpaceViewerPostActionMode = "draft-post" | "hidden" | "like-only";
export interface SpaceViewerDraftPostEdit {
cropArea?: SpaceImageCropArea;
@@ -95,17 +88,15 @@ export interface SpaceViewerDraftPostEdit {
interface SpaceViewerPostActionConfig {
showLikeButton: boolean;
- showLikeCountButton: boolean;
}
const spaceViewerPostActionConfigs: Record<
SpaceViewerPostActionMode,
SpaceViewerPostActionConfig
> = {
- "draft-post": { showLikeButton: false, showLikeCountButton: false },
- hidden: { showLikeButton: false, showLikeCountButton: false },
- "like-only": { showLikeButton: true, showLikeCountButton: false },
- "own-post-likes": { showLikeButton: false, showLikeCountButton: true },
+ "draft-post": { showLikeButton: false },
+ hidden: { showLikeButton: false },
+ "like-only": { showLikeButton: true },
};
export interface SpaceViewerPhoto {
@@ -115,7 +106,6 @@ export interface SpaceViewerPhoto {
friendID?: string;
height?: number;
imageUrl: string;
- likeCount?: number;
name: string;
postId?: number;
timestampMs: number;
@@ -136,7 +126,6 @@ interface SpaceFileViewerProps {
onDeletePost?: () => Promise<void> | void;
onDraftPostPublished?: () => void;
onAddFriendForPostAction?: () => void;
- onLoadPostLikers?: SpacePostLikersLoader;
onOpenProfile?: () => void;
onPublishDraftPost?: (
caption: string,
@@ -283,7 +272,6 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
onDeletePost,
onDraftPostPublished,
onAddFriendForPostAction,
- onLoadPostLikers,
onOpenProfile,
onPublishDraftPost,
onReplyToPost,
@@ -298,10 +286,8 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
}) => {
const activePostActionMode = postActionMode;
const isDraftPost = activePostActionMode == "draft-post";
- const {
- showLikeButton: showPhotoLikeButton,
- showLikeCountButton: showPhotoLikeCountButton,
- } = spaceViewerPostActionConfigs[activePostActionMode];
+ const { showLikeButton: showPhotoLikeButton } =
+ spaceViewerPostActionConfigs[activePostActionMode];
const canDeletePost = !isDraftPost && Boolean(onDeletePost);
const [deleteActionPhase, setDeleteActionPhase] =
React.useState<SpaceActionPhase | null>(null);
@@ -374,13 +360,6 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
const [addFriendSheetOpen, setAddFriendSheetOpen] = React.useState(false);
const [addFriendPostAction, setAddFriendPostAction] =
React.useState<AddFriendPostAction>("like");
- 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);
@@ -423,7 +402,6 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
isActionsOpen ||
addFriendSheetOpen ||
(canDeletePost && deleteSheetOpen) ||
- postLikersOpen ||
isDeleteExit ||
isDraftPost ||
isDraftPostPreviewPending;
@@ -464,43 +442,6 @@ 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 = () => {
@@ -713,12 +654,7 @@ 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(() => {
@@ -937,7 +873,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
React.useEffect(() => {
const closeOnEscape = (event: KeyboardEvent) => {
- if (deleteSheetOpen || postLikersOpen) return;
+ if (deleteSheetOpen) return;
if (event.key != "Escape") return;
onCloseRef.current();
@@ -945,7 +881,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
window.addEventListener("keydown", closeOnEscape);
return () => window.removeEventListener("keydown", closeOnEscape);
- }, [deleteSheetOpen, postLikersOpen]);
+ }, [deleteSheetOpen]);
return (
<Box
@@ -1744,84 +1680,6 @@ 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: viewerLikeCountText,
- cursor:
- activePhoto.postId && onLoadPostLikers
- ? "pointer"
- : "default",
- display: "inline-flex",
- fontFamily: '"Inter Variable", Inter, sans-serif',
- fontSize: 14,
- fontWeight: 750,
- height: 48,
- gap: "5px",
- justifyContent: "center",
- lineHeight: "20px",
- minWidth: 48,
- p: 0,
- px: "2px",
- "&: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={24}
- strokeWidth={1.8}
- />
- </Box>
- <Box
- component="span"
- sx={{
- color: "currentColor",
- fontFamily:
- '"Inter Variable", Inter, sans-serif',
- fontSize: 14,
- fontWeight: 750,
- lineHeight: "20px",
- transform: "translateY(0.5px)",
- }}
- >
- {activePhoto.likeCount ?? 0}
- </Box>
- </Box>
- </Box>
- )}
{canDeletePost && (
<ConfirmationActionSheet
appearance="dark"
@@ -1847,13 +1705,6 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
onConfirm={confirmAddFriendForPostAction}
/>
)}
- <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.tsx
deleted file mode 100644
index 251969afe1..0000000000
--- a/web/apps/space/src/components/SpacePostLikersDialog.tsx
+++ /dev/null
@@ -1,248 +0,0 @@
-import { Box, CircularProgress, Dialog, useMediaQuery } from "@mui/material";
-import { SpaceAvatarImage } from "components/SpaceAvatarImage";
-import { SpaceBottomSheetTransition } from "components/SpaceBottomSheetTransition";
-import React from "react";
-import type { SpacePostLiker } from "services/space";
-
-const textBase = "#F4F4F4";
-const textSecondary = "#A6A6A6";
-const lightTextBase = "#000000";
-const lightTextSecondary = "#777777";
-const dangerColor = "#F63A3A";
-const green = "#1DB954";
-const sheetBackground = "#1E1E1E";
-const lightSheetBackground = "#F2F2F2";
-const avatarBackground = "#333333";
-const lightAvatarBackground = "#E6E6E6";
-const darkBackdropBackground = "rgba(0, 0, 0, 0.86)";
-const lightBackdropBackground = "rgba(255, 255, 255, 0.72)";
-const likersPanelHeight = "min(180px, 36vh)";
-
-interface SpacePostLikersDialogProps {
- appearance?: "dark" | "light";
- errorMessage?: string | null;
- likers: SpacePostLiker[];
- loading: boolean;
- open: boolean;
- onClose: () => void;
-}
-
-export const SpacePostLikersDialog: React.FC<SpacePostLikersDialogProps> = ({
- appearance = "dark",
- errorMessage,
- likers,
- loading,
- open,
- onClose,
-}) => {
- const isBottomSheet = useMediaQuery("(max-width: 599px)");
- const isLight = appearance == "light";
- const panelBackground = isLight ? lightSheetBackground : sheetBackground;
- const primaryText = isLight ? lightTextBase : textBase;
- const secondaryText = isLight ? lightTextSecondary : textSecondary;
- const avatarFill = isLight ? lightAvatarBackground : avatarBackground;
- const backdropBackground = isLight
- ? lightBackdropBackground
- : darkBackdropBackground;
-
- return (
- <Dialog
- open={open}
- onClose={onClose}
- maxWidth={false}
- aria-label="Likes"
- slots={
- isBottomSheet
- ? { transition: SpaceBottomSheetTransition }
- : undefined
- }
- sx={{
- zIndex: 1500,
- "& .MuiBackdrop-root": {
- backgroundColor: `${backdropBackground} !important`,
- },
- "& .MuiDialog-container": { backgroundColor: "transparent" },
- "& .MuiPaper-root": {
- backgroundColor: `${panelBackground} !important`,
- },
- }}
- slotProps={{
- backdrop: { sx: { backgroundColor: backdropBackground } },
- paper: {
- sx: {
- bgcolor: panelBackground,
- backgroundColor: panelBackground,
- border: 0,
- 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={{ height: likersPanelHeight, overflowY: "auto" }}>
- {loading ? (
- <Box
- sx={{
- alignItems: "center",
- display: "flex",
- height: "100%",
- justifyContent: "center",
- }}
- >
- <CircularProgress
- aria-label="Loading likes"
- size={24}
- thickness={4}
- sx={{ color: green }}
- />
- </Box>
- ) : errorMessage ? (
- <Box
- role="alert"
- sx={{
- alignItems: "center",
- color: dangerColor,
- display: "flex",
- fontFamily:
- '"Inter Variable", Inter, sans-serif',
- fontSize: 13,
- fontWeight: 650,
- justifyContent: "center",
- lineHeight: "18px",
- minHeight: "100%",
- textAlign: "center",
- }}
- >
- {errorMessage}
- </Box>
- ) : likers.length == 0 ? (
- <Box
- sx={{
- alignItems: "center",
- color: secondaryText,
- display: "flex",
- fontFamily:
- '"Inter Variable", Inter, sans-serif',
- fontSize: 14,
- fontWeight: 600,
- justifyContent: "center",
- lineHeight: "20px",
- minHeight: "100%",
- 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}`}
- avatarFill={avatarFill}
- liker={liker}
- textColor={primaryText}
- />
- ))}
- </Box>
- )}
- </Box>
- </Box>
- </Dialog>
- );
-};
-
-const SpacePostLikerRow: React.FC<{
- avatarFill: string;
- liker: SpacePostLiker;
- textColor: string;
-}> = ({ avatarFill, liker, textColor }) => {
- 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: "28px minmax(0, 1fr) 24px",
- minHeight: 38,
- py: "4px",
- }}
- >
- <Box
- sx={{
- bgcolor: avatarFill,
- borderRadius: "50%",
- height: 28,
- overflow: "hidden",
- width: 28,
- }}
- >
- <SpaceAvatarImage src={profile.avatarUrl} />
- </Box>
- <Box
- sx={{
- color: textColor,
- fontFamily: '"Inter Variable", Inter, sans-serif',
- fontSize: 14,
- 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.tsx
index 91f279bbdd..afbba4e5c9 100644
--- a/web/apps/space/src/pages/app/index.tsx
+++ b/web/apps/space/src/pages/app/index.tsx
@@ -7,7 +7,6 @@ import {
createCurrentProfileLink,
deleteCurrentPost,
loadCurrentFeedPage,
- loadCurrentPostLikers,
loadCurrentSpaceFriends,
loadCurrentSpacePostAssetURL,
loadCurrentSpacePostAvatarURL,
@@ -288,7 +287,6 @@ const Page: React.FC = () => {
onLoadMoreFeedItems={loadMoreFeedItems}
onLoadPostAvatar={loadCurrentSpacePostAvatarURL}
onLoadPostImage={loadCurrentSpacePostAssetURL}
- onLoadPostLikers={loadCurrentPostLikers}
onOpenMessages={() => void router.push(spaceRoutes.messages)}
onOpenProfile={
profile
diff --git a/web/apps/space/src/pages/app/posts/[spaceId]/[postId].tsx b/web/apps/space/src/pages/app/posts/[spaceId]/[postId].tsx
index 2d3b1bbea1..c80310e159 100644
--- a/web/apps/space/src/pages/app/posts/[spaceId]/[postId].tsx
+++ b/web/apps/space/src/pages/app/posts/[spaceId]/[postId].tsx
@@ -3,7 +3,6 @@ import { SpacePageMeta } from "components/SpacePageMeta";
import { SpaceRouteFallback } from "components/SpaceRouteFallback";
import React from "react";
import {
- loadCurrentPostLikers,
loadCurrentSpacePost,
replyToCurrentPost,
setCurrentPostLiked,
@@ -51,7 +50,6 @@ 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,
@@ -150,9 +148,8 @@ const Page: React.FC = () => {
/>
<SpaceFileViewer
photo={viewerPhotoFromPost(post)}
- postActionMode={isOwnPost ? "own-post-likes" : "like-only"}
+ postActionMode={isOwnPost ? "hidden" : "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.tsx
index c4d5896e4d..0d34bde97a 100644
--- a/web/apps/space/src/pages/app/profile.tsx
+++ b/web/apps/space/src/pages/app/profile.tsx
@@ -5,7 +5,6 @@ import { ProfileScreen, profileBackground } from "screens/ProfileScreen";
import {
createCurrentPhotoPost,
deleteCurrentPost,
- loadCurrentPostLikers,
loadCurrentSpaceFriendsCount,
loadCurrentSpacePostAssetURL,
loadCurrentSpaceProfilePostsPage,
@@ -190,7 +189,6 @@ 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.tsx
index 6bd5442ef8..12a1e78d9e 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -6,6 +6,7 @@ import {
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import { Box, Skeleton } from "@mui/material";
+import { SpaceAvatarImage } from "components/SpaceAvatarImage";
import {
SpaceFileViewer,
SpaceViewerFeedBackdrop,
@@ -13,7 +14,6 @@ import {
type SpaceViewerPhoto,
type SpaceViewerPostActionMode,
} from "components/SpaceFileViewer";
-import { SpaceAvatarImage } from "components/SpaceAvatarImage";
import { SpaceInviteFriendsDialog } from "components/SpaceInviteFriendsDialog";
import { SpacePostFloatingActionButton } from "components/SpacePostFloatingActionButton";
import {
@@ -22,7 +22,6 @@ import {
spacePostLikePopDurationMs,
spacePostLikePopTiming,
} from "components/SpacePostLikeAnimation";
-import { SpacePostLikersDialog } from "components/SpacePostLikersDialog";
import { SpaceLoadingSpinner } from "components/SpaceRouteFallback";
import { useBrowserBackClose } from "hooks/useBrowserBackClose";
import React, { useState } from "react";
@@ -32,8 +31,6 @@ import type {
SpacePost,
SpacePostAssetURLLoader,
SpacePostAvatarURLLoader,
- SpacePostLiker,
- SpacePostLikersLoader,
} from "services/space";
import type { LocalSpaceFeedPost } from "state/spaceAppState";
import { spaceTouchTargetSize } from "styles/touchTargets";
@@ -123,7 +120,6 @@ interface HomeScreenProps {
onLoadMoreFeedItems?: () => Promise<void> | void;
onLoadPostAvatar?: SpacePostAvatarURLLoader;
onLoadPostImage?: SpacePostAssetURLLoader;
- onLoadPostLikers?: SpacePostLikersLoader;
onOpenFriend?: (friendID: string) => void;
onOpenMessages?: () => void;
onOpenProfile?: () => void;
@@ -178,11 +174,9 @@ interface FeedItemProps {
imageUrl?: string;
isAvatarPending: boolean;
isOwnPost: boolean;
- likeCount?: number;
name: string;
onLoadAvatar?: () => Promise<string | null | undefined>;
onLoadImage?: () => Promise<string | undefined>;
- onLoadPostLikers?: SpacePostLikersLoader;
onOpenFriend?: (friendID: string) => void;
onOpenPhoto?: (photo: SpaceViewerPhoto, focusReplyOnOpen?: boolean) => void;
onOpenProfile?: () => void;
@@ -463,11 +457,12 @@ const FeedSkeletonItem: React.FC<FeedSkeletonItemProps> = ({
boxSizing: "border-box",
display: "grid",
gap: "8px",
- gridTemplateColumns: "minmax(0, 1fr) auto",
+ gridTemplateColumns: isOwnPost
+ ? "minmax(0, 1fr)"
+ : "minmax(0, 1fr) auto",
minHeight: feedLikeActionSize,
mt: "8px",
pl: "9px",
- pr: isOwnPost ? "3px" : 0,
width: "100%",
}}
>
@@ -482,20 +477,7 @@ const FeedSkeletonItem: React.FC<FeedSkeletonItemProps> = ({
width: "60%",
}}
/>
- {isOwnPost ? (
- <Skeleton
- variant="rectangular"
- sx={{
- bgcolor: feedActionBackground,
- borderRadius: "999px",
- height: 14,
- justifySelf: "flex-end",
- mr: "4px",
- transform: "none",
- width: 34,
- }}
- />
- ) : (
+ {!isOwnPost && (
<Box
sx={{
alignItems: "center",
@@ -641,11 +623,9 @@ const FeedItem: React.FC<FeedItemProps> = ({
imageUrl,
isAvatarPending,
isOwnPost,
- likeCount = 0,
name,
onLoadAvatar,
onLoadImage,
- onLoadPostLikers,
onOpenFriend,
onOpenPhoto,
onOpenProfile,
@@ -665,9 +645,7 @@ const FeedItem: React.FC<FeedItemProps> = ({
const dateLabel = formatSpaceDate(timestampMs);
const postingDotCount = usePostingDotCount(timestampStatus == "posting");
const displayCaption = caption?.trim();
- const showOwnPostLikeButton = isOwnPost && postId > 0;
- const showFooter =
- !isOwnPost || Boolean(displayCaption) || showOwnPostLikeButton;
+ const showFooter = !isOwnPost || Boolean(displayCaption);
const canOpenAuthor = isOwnPost
? Boolean(onOpenProfile)
: Boolean(onOpenFriend);
@@ -735,7 +713,6 @@ const FeedItem: React.FC<FeedItemProps> = ({
friendID,
height: photoDimensions.height,
imageUrl: displayImageUrl,
- likeCount,
name,
postId,
timestampMs,
@@ -1094,12 +1071,11 @@ const FeedItem: React.FC<FeedItemProps> = ({
display: "grid",
gap: "8px",
gridTemplateColumns: isOwnPost
- ? "minmax(0, 1fr) auto"
+ ? "minmax(0, 1fr)"
: "minmax(0, 1fr) auto",
minHeight: feedLikeActionSize,
mt: "8px",
pl: "9px",
- pr: isOwnPost ? "3px" : 0,
width: "100%",
}}
>
@@ -1182,149 +1158,12 @@ const FeedItem: React.FC<FeedItemProps> = ({
/>
</Box>
)}
- {showOwnPostLikeButton && (
- <FeedOwnPostLikeButton
- likeCount={likeCount}
- onLoadPostLikers={onLoadPostLikers}
- postId={postId}
- />
- )}
</Box>
)}
</Box>
);
};
-const FeedOwnPostLikeButton: React.FC<{
- likeCount: number;
- onLoadPostLikers?: SpacePostLikersLoader;
- postId: number;
-}> = ({ likeCount, onLoadPostLikers, postId }) => {
- 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 openPostLikers = () => {
- if (!onLoadPostLikers) return;
-
- const requestID = postLikersRequestIDRef.current + 1;
- postLikersRequestIDRef.current = requestID;
- setPostLikersOpen(true);
- setPostLikersLoading(true);
- setPostLikersError(null);
-
- void onLoadPostLikers(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);
- };
-
- React.useEffect(() => {
- postLikersRequestIDRef.current += 1;
- setPostLikers([]);
- setPostLikersError(null);
- setPostLikersLoading(false);
- setPostLikersOpen(false);
- }, [postId]);
-
- return (
- <>
- <Box
- component="button"
- type="button"
- aria-label={`View ${likeCount} likes`}
- disabled={!onLoadPostLikers}
- onClick={openPostLikers}
- sx={{
- alignItems: "center",
- appearance: "none",
- bgcolor: "transparent",
- border: 0,
- borderRadius: "8px",
- color: textBase,
- cursor: onLoadPostLikers ? "pointer" : "default",
- display: "inline-flex",
- fontFamily: '"Inter Variable", Inter, sans-serif',
- fontSize: 13,
- fontWeight: 750,
- gap: "4px",
- height: feedLikeActionSize,
- justifyContent: "center",
- justifySelf: "flex-end",
- lineHeight: "18px",
- minWidth: feedLikeActionSize,
- px: "6px",
- "&:disabled": { opacity: 1 },
- "&:focus-visible": {
- outline: `2px solid ${green}`,
- outlineOffset: 2,
- },
- }}
- >
- <Box
- component="span"
- sx={{
- alignItems: "center",
- display: "flex",
- lineHeight: 0,
- }}
- >
- <HugeiconsIcon
- fill="none"
- icon={FavouriteIcon}
- primaryColor="currentColor"
- size={feedActionIconSize}
- strokeWidth={2}
- />
- </Box>
- <Box
- component="span"
- sx={{
- color: "currentColor",
- transform: "translateY(0.5px)",
- }}
- >
- {likeCount}
- </Box>
- </Box>
- <SpacePostLikersDialog
- appearance="light"
- errorMessage={postLikersError}
- likers={postLikers}
- loading={postLikersLoading}
- open={postLikersOpen}
- onClose={closePostLikers}
- />
- </>
- );
-};
-
const AddedFriendToast: React.FC<AddedFriendToastProps> = ({
name,
onClose,
@@ -1436,7 +1275,6 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
onLoadMoreFeedItems,
onLoadPostAvatar,
onLoadPostImage,
- onLoadPostLikers,
onOpenFriend,
onOpenMessages,
onOpenProfile,
@@ -1522,7 +1360,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
setSelectedViewer({
focusReplyOnOpen: isOwnPost ? false : focusReplyOnOpen,
photo,
- postActionMode: isOwnPost ? "own-post-likes" : "like-only",
+ postActionMode: isOwnPost ? "hidden" : "like-only",
});
};
const closeSelectedPhoto = () => {
@@ -1651,17 +1489,13 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
isOwnPost={
Boolean(profileSpaceId) && item.spaceId == profileSpaceId
}
- likeCount={item.likeCount}
name={item.name}
onLoadAvatar={
- isAvatarPending
- ? () => loadFeedPostAvatar(item)
- : undefined
+ isAvatarPending ? () => loadFeedPostAvatar(item) : undefined
}
onLoadImage={
imageUrl ? undefined : () => loadFeedPostImage(item)
}
- onLoadPostLikers={onLoadPostLikers}
onOpenFriend={onOpenFriend}
onOpenPhoto={openFeedPhoto}
onOpenProfile={onOpenProfile}
@@ -2346,7 +2180,6 @@ 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.tsx
index 2977fa6f71..a366f534b8 100644
--- a/web/apps/space/src/screens/ProfileScreen.tsx
+++ b/web/apps/space/src/screens/ProfileScreen.tsx
@@ -17,7 +17,7 @@ import { SpacePostFloatingActionButton } from "components/SpacePostFloatingActio
import { useBrowserBackClose } from "hooks/useBrowserBackClose";
import React, { useState } from "react";
import type { SetupProfile } from "screens/SetupProfileScreen";
-import type { SpacePostAsset, SpacePostLikersLoader } from "services/space";
+import type { SpacePostAsset } from "services/space";
import { spaceTouchTargetSize } from "styles/touchTargets";
import { createLoadedLocalPostPhoto } from "utils/localPostPhoto";
import { firstNameFrom } from "utils/spaceDisplay";
@@ -66,7 +66,6 @@ export interface ProfilePostItem {
id: string;
imageAsset?: SpacePostAsset;
imageUrl?: string;
- likeCount?: number;
name?: string;
postId?: number;
timestampMs: number;
@@ -403,7 +402,6 @@ 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[];
@@ -427,7 +425,6 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
onOpenProfilePhoto,
onOpenSettings,
onLoadPostImage,
- onLoadPostLikers,
onReplyToPost,
onSetPostLiked,
postGroups = [],
@@ -493,7 +490,7 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
const selectedPostActionMode: SpaceViewerPostActionMode = isPublicProfile
? "like-only"
: isOwnerProfile
- ? "own-post-likes"
+ ? "hidden"
: "like-only";
const revokeLocalPostObjectUrls = React.useCallback(() => {
@@ -608,7 +605,6 @@ 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,
@@ -638,7 +634,6 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
name: displayName,
postId: item.postId,
timestampMs: item.timestampMs,
- likeCount: item.likeCount ?? 0,
viewerLiked: item.viewerLiked,
width: dimensions.width,
};
@@ -1617,7 +1612,6 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
onAddFriendForPostAction={
isPublicProfile ? onAddFriend : undefined
}
- onLoadPostLikers={onLoadPostLikers}
onOpenProfile={closeSelectedPost}
onReplyToPost={
isFriendProfile ? onReplyToPost : undefined
diff --git a/web/apps/space/src/services/space.ts b/web/apps/space/src/services/space.ts
index df2689f49a..de082e85da 100644
--- a/web/apps/space/src/services/space.ts
+++ b/web/apps/space/src/services/space.ts
@@ -12,7 +12,6 @@ import {
import { normalizeSpaceMessageText } from "utils/spaceMessageLimits";
const currentFeedPageSize = 10;
-const postLikersPageSize = 100;
interface SpaceAvatar {
objectKey: string;
@@ -64,7 +63,6 @@ interface SpacePostResponse {
createdAt: string;
encryptedPostKey: string;
keyVersion: number;
- likes?: number;
objects?: SpacePostObject[];
postId: number;
viewerLiked: boolean;
@@ -77,16 +75,6 @@ interface SpacePostPageResponse {
nextCursor?: string;
}
-interface SpacePostLikerResponse {
- actor: SpaceActor;
- createdAt: string;
-}
-
-interface SpacePostLikersPageResponse {
- likers?: SpacePostLikerResponse[];
- nextCursor?: string;
-}
-
type SpaceMessageConversationActivityType =
| "friend_add"
| "friend_remove"
@@ -175,7 +163,6 @@ interface SpacePostBase {
caption?: string;
friendID: string;
height?: number;
- likeCount: number;
name: string;
postId: number;
timestampMs: number;
@@ -213,15 +200,6 @@ 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>;
@@ -682,7 +660,6 @@ 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),
@@ -708,7 +685,6 @@ 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),
@@ -742,19 +718,6 @@ 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,
@@ -1006,9 +969,7 @@ export const loadCurrentUnreadStatus = async (): Promise<SpaceUnreadStatus> => {
const ctx = await ensureCurrentSpaceContext();
try {
const status = (await ctx.unread_status()) as SpaceUnreadStatusResponse;
- return {
- messagesUnread: status.notificationsUnread,
- };
+ return { messagesUnread: status.notificationsUnread };
} finally {
releaseCurrentSpaceContext(ctx);
}
@@ -1160,34 +1121,6 @@ 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.ts
index 1119073115..0fdcd035e6 100644
--- a/web/apps/space/src/utils/spacePostDisplay.ts
+++ b/web/apps/space/src/utils/spacePostDisplay.ts
@@ -29,7 +29,6 @@ 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,