Skip to content

armgit / ente

Public Imported from GitHub
0

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

Remove social app comments code

Anand Baburajan3e9683c0e910
diff --git a/web/apps/social/src/components/SocialFileViewer.tsx b/web/apps/social/src/components/SocialFileViewer.tsx
index 8083d9aa5c..07442645b3 100644
--- a/web/apps/social/src/components/SocialFileViewer.tsx
+++ b/web/apps/social/src/components/SocialFileViewer.tsx
@@ -1,23 +1,17 @@
import {
Cancel01Icon,
- Comment01Icon,
Delete02Icon,
FavouriteIcon,
- Loading03Icon,
MoreHorizontalIcon,
- Navigation03Icon,
- Tick02Icon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-import { Box, Menu, MenuItem, TextField } from "@mui/material";
-import { keyframes } from "@mui/material/styles";
+import { Box, Menu, MenuItem } from "@mui/material";
import { ConfirmationActionSheet } from "components/ConfirmationActionSheet";
import {
socialActionBusyDurationMs,
socialActionDoneDurationMs,
type SocialActionPhase,
} from "components/SocialActionFeedback";
-import { formatTimeAgo } from "ente-base/date";
import type PhotoSwipe from "photoswipe";
import React from "react";
import {
@@ -41,35 +35,16 @@ const viewerBottomPadding = 72;
const defaultPhotoWidth = 900;
const defaultPhotoHeight = 680;
const viewerExitDurationMs = 200;
-const viewerIntroTransition = "160ms cubic-bezier(0.2, 0, 0, 1)";
const viewerExitTransition = `${viewerExitDurationMs}ms cubic-bezier(0.4, 0, 0.2, 1)`;
-const commentsBackground = "#202020";
-const commentsSurface = "#2C2C2C";
-const commentsSurfaceHover = "#343434";
-const commentsOwnerBubble = "#3FA43D";
-const commentsMuted = "rgba(244, 244, 244, 0.54)";
-const commentsTimestamp = "rgba(255, 255, 255, 0.55)";
-const commentSendPendingDurationMs = 1500;
-const captionSendDoneDurationMs = 1500;
-const captionComposerExitDurationMs = 260;
-const captionActionsEnterDurationMs = 160;
-
-const commentSendSpin = keyframes`
- from {
- transform: rotate(0deg);
- }
-
- to {
- transform: rotate(360deg);
- }
-`;
+const viewerPanelBackground = "#202020";
+const viewerPanelMuted = "rgba(244, 244, 244, 0.54)";
interface SocialViewerUser {
avatarUrl?: string | null;
name: string;
}
-export type SocialViewerInitialScreen = "photo" | "comments" | "likes";
+export type SocialViewerInitialScreen = "photo" | "likes";
export type SocialViewerPostActionMode =
| "hidden"
@@ -77,7 +52,6 @@ export type SocialViewerPostActionMode =
| "like-with-count";
interface SocialViewerPostActionConfig {
- showCommentButton: boolean;
showLikeButton: boolean;
showLikeCount: boolean;
}
@@ -86,21 +60,9 @@ const socialViewerPostActionConfigs: Record<
SocialViewerPostActionMode,
SocialViewerPostActionConfig
> = {
- hidden: {
- showCommentButton: false,
- showLikeButton: false,
- showLikeCount: false,
- },
- "like-only": {
- showCommentButton: false,
- showLikeButton: true,
- showLikeCount: false,
- },
- "like-with-count": {
- showCommentButton: false,
- showLikeButton: true,
- showLikeCount: true,
- },
+ hidden: { showLikeButton: false, showLikeCount: false },
+ "like-only": { showLikeButton: true, showLikeCount: false },
+ "like-with-count": { showLikeButton: true, showLikeCount: true },
};
export interface SocialViewerPhoto {
@@ -123,18 +85,6 @@ interface SocialFileViewerProps {
onOpenProfile?: () => void;
photo: SocialViewerPhoto;
postActionMode?: SocialViewerPostActionMode;
- showPostCaptionInput?: boolean;
-}
-
-interface SocialComment {
- id: string;
- author: string;
- avatarUrl?: string | null;
- createdAtMicros: number;
- isDeleted?: boolean;
- isOwner?: boolean;
- parentCommentID?: string;
- text: string;
}
interface SocialLiker {
@@ -144,239 +94,6 @@ interface SocialLiker {
name: string;
}
-interface CommentContextMenuState {
- anchorEl: HTMLElement;
- comment: SocialComment;
-}
-
-type CommentSendPhase = "idle" | "sending" | "done";
-
-const minuteMs = 60 * 1000;
-const hourMs = 60 * minuteMs;
-const dayMs = 24 * hourMs;
-const commentGroupTimeThresholdMicros = 10 * minuteMs * 1000;
-const microsForTimestamp = (timestampMs: number) => timestampMs * 1000;
-const microsAgo = (durationMs: number) =>
- microsForTimestamp(Date.now() - durationMs);
-
-const mockComments: SocialComment[] = [
- {
- id: "kabir-plan",
- author: "Kabir Menon",
- avatarUrl: "/images/sample-feed-1.jpg",
- createdAtMicros: microsAgo(6 * minuteMs),
- text: "This is the overlook near the old forest road, right?",
- },
- {
- id: "you-kabir-plan",
- author: "You",
- avatarUrl: "/images/sample-feed-6.jpg",
- createdAtMicros: microsAgo(5 * minuteMs),
- isOwner: true,
- parentCommentID: "kabir-plan",
- text: "Yes. We took the smaller trail behind the tea stall.",
- },
- {
- id: "you-kabir-plan-2",
- author: "You",
- avatarUrl: "/images/sample-feed-6.jpg",
- createdAtMicros: microsAgo(4 * minuteMs + 45 * 1000),
- isOwner: true,
- text: "The first marker is easy to miss.",
- },
- {
- id: "you-kabir-plan-3",
- author: "You",
- avatarUrl: "/images/sample-feed-6.jpg",
- createdAtMicros: microsAgo(4 * minuteMs + 30 * 1000),
- isOwner: true,
- parentCommentID: "you-kabir-plan-2",
- text: "If you hit the stream crossing, you have gone too far.",
- },
- {
- id: "kabir-followup",
- author: "Kabir Menon",
- avatarUrl: "/images/sample-feed-1.jpg",
- createdAtMicros: microsAgo(4 * minuteMs),
- parentCommentID: "you-kabir-plan",
- text: "Nice, adding this to the Sunday route.",
- },
- {
- id: "nikhil",
- author: "Nikhil Rao",
- avatarUrl: "/images/sample-feed-5.jpg",
- createdAtMicros: microsAgo(22 * minuteMs),
- text: "This trail needs to be on our next trip list.",
- },
- {
- id: "nikhil-chain-1",
- author: "Nikhil Rao",
- avatarUrl: "/images/sample-feed-5.jpg",
- createdAtMicros: microsAgo(21 * minuteMs),
- text: "The ridge looks quiet enough for a picnic stop too.",
- },
- {
- id: "you-nikhil",
- author: "You",
- avatarUrl: "/images/sample-feed-6.jpg",
- createdAtMicros: microsAgo(20 * minuteMs),
- isOwner: true,
- parentCommentID: "nikhil-chain-1",
- text: "It was quiet until about 9. After that it filled up fast.",
- },
- {
- id: "mira",
- author: "Mira Sen",
- avatarUrl: "/images/sample-feed-3.jpg",
- createdAtMicros: microsAgo(34 * minuteMs),
- text: "The colors in this shot are so good.",
- },
- {
- id: "you-reply-mira",
- author: "You",
- avatarUrl: "/images/sample-feed-6.jpg",
- createdAtMicros: microsAgo(32 * minuteMs),
- isOwner: true,
- parentCommentID: "mira",
- text: "That evening light did all the work.",
- },
- {
- id: "mira-followup",
- author: "Mira Sen",
- avatarUrl: "/images/sample-feed-3.jpg",
- createdAtMicros: microsAgo(31 * minuteMs),
- parentCommentID: "you-reply-mira",
- text: "Still counts. You noticed it at the right time.",
- },
- {
- id: "aparna",
- author: "Aparna Bhatnagar",
- avatarUrl: "/images/sample-feed-4.jpg",
- createdAtMicros: microsAgo(52 * minuteMs),
- text: "The framing is perfect.",
- },
- {
- id: "mira-reply",
- author: "Mira Sen",
- avatarUrl: "/images/sample-feed-3.jpg",
- createdAtMicros: microsAgo(50 * minuteMs),
- parentCommentID: "aparna",
- text: "Agree, the path pulls you right in.",
- },
- {
- id: "aparna-reply-mira",
- author: "Aparna Bhatnagar",
- avatarUrl: "/images/sample-feed-4.jpg",
- createdAtMicros: microsAgo(49 * minuteMs),
- parentCommentID: "mira-reply",
- text: "Exactly. The leading line is doing everything.",
- },
- {
- id: "devika",
- author: "Isha Mehta",
- avatarUrl: "/images/sample-feed-2.jpg",
- createdAtMicros: microsAgo(74 * minuteMs),
- text: "Saving this for the weekend plan.",
- },
- {
- id: "you-reply-devika",
- author: "You",
- avatarUrl: "/images/sample-feed-6.jpg",
- createdAtMicros: microsAgo(72 * minuteMs),
- isOwner: true,
- parentCommentID: "devika",
- text: "Go early if you want the quiet stretch.",
- },
- {
- id: "devika-route",
- author: "Isha Mehta",
- avatarUrl: "/images/sample-feed-2.jpg",
- createdAtMicros: microsAgo(70 * minuteMs),
- parentCommentID: "you-reply-devika",
- text: "Good call. I will try sunrise.",
- },
- {
- id: "you-devika-route",
- author: "You",
- avatarUrl: "/images/sample-feed-6.jpg",
- createdAtMicros: microsAgo(69 * minuteMs),
- isOwner: true,
- parentCommentID: "devika-route",
- text: "Carry water. There is nothing open before the bend.",
- },
- {
- id: "kabir",
- author: "Kabir Menon",
- avatarUrl: "/images/sample-feed-1.jpg",
- createdAtMicros: microsAgo(3 * hourMs),
- text: "Looks peaceful. Was it crowded?",
- },
- {
- id: "you-crowd-reply",
- author: "You",
- avatarUrl: "/images/sample-feed-6.jpg",
- createdAtMicros: microsAgo(3 * hourMs - 5 * minuteMs),
- isOwner: true,
- parentCommentID: "kabir",
- text: "Not really. We went just after sunrise.",
- },
- {
- id: "kabir-crowd-2",
- author: "Kabir Menon",
- avatarUrl: "/images/sample-feed-1.jpg",
- createdAtMicros: microsAgo(3 * hourMs - 8 * minuteMs),
- parentCommentID: "you-crowd-reply",
- text: "That explains the empty path. Worth the early alarm.",
- },
- {
- id: "you-crowd-3",
- author: "You",
- avatarUrl: "/images/sample-feed-6.jpg",
- createdAtMicros: microsAgo(3 * hourMs - 10 * minuteMs),
- isOwner: true,
- parentCommentID: "kabir-crowd-2",
- text: "The first half hour was the best part.",
- },
- {
- id: "samar",
- author: "Aparna Bhatnagar",
- avatarUrl: "/images/sample-feed-4.jpg",
- createdAtMicros: microsAgo(3 * dayMs),
- text: "The composition makes it feel cinematic.",
- },
- {
- id: "samar-2",
- author: "Aparna Bhatnagar",
- avatarUrl: "/images/sample-feed-4.jpg",
- createdAtMicros: microsAgo(3 * dayMs - 8 * minuteMs),
- text: "Also love that the sky is not overdone.",
- },
- {
- id: "leena",
- author: "Riya Kapoor",
- avatarUrl: "/images/sample-feed-6.jpg",
- createdAtMicros: microsAgo(8 * dayMs),
- text: "Need the exact location for this one.",
- },
- {
- id: "you-reply-leena",
- author: "You",
- avatarUrl: "/images/sample-feed-6.jpg",
- createdAtMicros: microsAgo(8 * dayMs - 34 * minuteMs),
- isOwner: true,
- parentCommentID: "leena",
- text: "I will send you the pin.",
- },
- {
- id: "leena-final",
- author: "Riya Kapoor",
- avatarUrl: "/images/sample-feed-6.jpg",
- createdAtMicros: microsAgo(8 * dayMs - 39 * minuteMs),
- parentCommentID: "you-reply-leena",
- text: "Perfect. This one is going on the list.",
- },
-];
-
const mockPhotoLikers: SocialLiker[] = [
{
id: "mira",
@@ -423,27 +140,6 @@ const friendIDForPersonName = (name: string): string | undefined => {
}
};
-const commentAuthorKey = (comment: SocialComment) =>
- comment.isOwner ? "current-user" : comment.author;
-
-const getParentComment = (
- parentCommentID: string | undefined,
- comments: SocialComment[],
-): SocialComment | undefined => {
- if (!parentCommentID) return undefined;
- return comments.find((comment) => comment.id == parentCommentID);
-};
-
-const truncateCommentText = (text: string): string => {
- const lines = text.split("\n");
- const firstLine = lines[0] ?? text;
- if (firstLine.length > 100) return `${firstLine.slice(0, 100)}...`;
- return lines.length > 1 ? `${firstLine}...` : firstLine;
-};
-
-const sameCommentAuthor = (first: SocialComment, second: SocialComment) =>
- commentAuthorKey(first) == commentAuthorKey(second);
-
const viewerActionButtonSx = {
alignItems: "center",
bgcolor: controlBackground,
@@ -530,64 +226,6 @@ const SocialAvatar: React.FC<{
</Box>
);
-const ReplyIcon: React.FC = () => (
- <svg
- width="12"
- height="9"
- viewBox="0 0 12 9"
- fill="none"
- xmlns="http://www.w3.org/2000/svg"
- >
- <path
- fillRule="evenodd"
- clipRule="evenodd"
- d="M4.5241 0.242677C4.62341 0.34442 4.67919 0.482337 4.67919 0.626134C4.67919 0.76993 4.62341 0.907847 4.5241 1.00959L1.89369 3.70102H7.68483C8.3587 3.70102 9.35854 3.9036 10.2042 4.52653C11.0775 5.17045 11.7507 6.23762 11.7507 7.86116C11.7507 8.00507 11.6948 8.14309 11.5953 8.24485C11.4959 8.34661 11.361 8.40378 11.2203 8.40378C11.0797 8.40378 10.9448 8.34661 10.8453 8.24485C10.7459 8.14309 10.69 8.00507 10.69 7.86116C10.69 6.59069 10.1844 5.84982 9.58481 5.40776C8.95761 4.94544 8.18899 4.78627 7.68483 4.78627H1.89369L4.5241 7.4777C4.5762 7.52738 4.61799 7.58728 4.64698 7.65384C4.67597 7.72041 4.69155 7.79226 4.69281 7.86512C4.69406 7.93798 4.68096 8.01035 4.65429 8.07791C4.62762 8.14548 4.58792 8.20686 4.53756 8.25839C4.4872 8.30991 4.42722 8.35053 4.36118 8.37782C4.29515 8.40512 4.22442 8.41852 4.15321 8.41723C4.082 8.41595 4.01178 8.4 3.94673 8.37034C3.88167 8.34068 3.82313 8.29792 3.77457 8.24461L0.23908 4.6271C0.139767 4.52536 0.0839844 4.38744 0.0839844 4.24364C0.0839844 4.09985 0.139767 3.96193 0.23908 3.86019L3.77457 0.242677C3.87401 0.141061 4.0088 0.0839844 4.14934 0.0839844C4.28987 0.0839844 4.42466 0.141061 4.5241 0.242677Z"
- fill="currentColor"
- stroke="currentColor"
- strokeWidth="0.166667"
- />
- </svg>
-);
-
-interface HeartIconProps {
- filled?: boolean;
- small?: boolean;
-}
-
-const HeartIcon: React.FC<HeartIconProps> = ({ filled, small }) => (
- <svg
- width={small ? "13" : "16"}
- height={small ? "11" : "14"}
- viewBox="0 0 16 14"
- fill={filled ? "#08C225" : "none"}
- xmlns="http://www.w3.org/2000/svg"
- >
- <path
- 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"
- stroke={filled ? "#08C225" : "currentColor"}
- strokeWidth="1.5"
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- </svg>
-);
-
-const DeleteIcon: React.FC = () => (
- <svg
- width="13"
- height="15"
- viewBox="0 0 13 15"
- fill="none"
- xmlns="http://www.w3.org/2000/svg"
- >
- <path
- d="M11.5 2.83203L11.0869 9.51543C10.9813 11.223 10.9285 12.0768 10.5005 12.6906C10.2889 12.9941 10.0165 13.2502 9.70047 13.4427C9.0614 13.832 8.206 13.832 6.49513 13.832C4.78208 13.832 3.92553 13.832 3.28603 13.442C2.96987 13.2492 2.69733 12.9926 2.48579 12.6886C2.05792 12.0738 2.0063 11.2188 1.90307 9.50883L1.5 2.83203M0.5 2.83333H12.5M9.2038 2.83333L8.74873 1.89449C8.4464 1.27084 8.2952 0.959013 8.03447 0.76454C7.97667 0.7214 7.9154 0.683027 7.85133 0.6498C7.5626 0.5 7.21607 0.5 6.523 0.5C5.81253 0.5 5.45733 0.5 5.16379 0.65608C5.09873 0.690673 5.03665 0.7306 4.97819 0.775447C4.71443 0.9778 4.56709 1.30103 4.27241 1.94751L3.86861 2.83333M4.83203 10.166V6.16602M8.16797 10.166V6.16602"
- stroke="currentColor"
- strokeLinecap="round"
- />
- </svg>
-);
-
const HeartFilledIcon: React.FC = () => (
<svg
width="18"
@@ -607,487 +245,6 @@ const HeartFilledIcon: React.FC = () => (
</svg>
);
-interface CommentItemProps {
- comment: SocialComment;
- isHighlighted: boolean;
- isLiked: boolean;
- isLastInSequence: boolean;
- onOpenActions: (comment: SocialComment, anchorEl: HTMLElement) => void;
- onOpenAuthorProfile?: () => void;
- parentComment?: SocialComment;
- showHeader: boolean;
- showOwnTimestamp: boolean;
-}
-
-const CommentItem: React.FC<CommentItemProps> = ({
- comment,
- isHighlighted,
- isLiked,
- isLastInSequence,
- onOpenActions,
- onOpenAuthorProfile,
- parentComment,
- showHeader,
- showOwnTimestamp,
-}) => {
- const isOwner = Boolean(comment.isOwner);
- const authorName = firstNameFrom(comment.author);
- const timestampLabel = formatTimeAgo(comment.createdAtMicros);
- const timestampDateTime = new Date(
- Math.floor(comment.createdAtMicros / 1000),
- ).toISOString();
- const parentAuthorName = parentComment
- ? firstNameFrom(parentComment.author)
- : undefined;
- const bubbleBorderRadius = isOwner
- ? isLastInSequence
- ? "20px 6px 20px 20px"
- : "20px 6px 6px 20px"
- : isLastInSequence
- ? "6px 20px 20px 20px"
- : "6px 20px 20px 6px";
-
- const handleContextMenu = (event: React.MouseEvent<HTMLElement>) => {
- const selection = window.getSelection();
- if (selection && selection.toString().length > 0) return;
-
- event.preventDefault();
- event.stopPropagation();
- onOpenActions(comment, event.currentTarget);
- };
-
- return (
- <Box
- component="li"
- data-comment-id={comment.id}
- sx={{
- alignItems: isOwner ? "flex-end" : "flex-start",
- display: "flex",
- flexDirection: "column",
- listStyle: "none",
- mb: isLastInSequence ? "24px" : "6px",
- maxWidth: "100%",
- minWidth: 0,
- position: "relative",
- width: "100%",
- zIndex: isHighlighted ? 2 : "auto",
- }}
- >
- {showHeader && (
- <Box
- sx={{
- alignItems: "center",
- color: "inherit",
- display: "flex",
- gap: "4px",
- maxWidth: "min(calc(100vw - 32px), 360px)",
- mb: "10px",
- minWidth: 0,
- textAlign: "left",
- width: "100%",
- }}
- >
- <Box
- component={onOpenAuthorProfile ? "button" : "div"}
- type={onOpenAuthorProfile ? "button" : undefined}
- onClick={onOpenAuthorProfile}
- sx={{
- alignItems: "center",
- appearance: "none",
- bgcolor: "transparent",
- border: 0,
- color: "inherit",
- cursor: onOpenAuthorProfile ? "pointer" : "default",
- display: "flex",
- flex: "0 1 auto",
- gap: "10px",
- minWidth: 0,
- p: 0,
- textAlign: "left",
- width: "fit-content",
- maxWidth: "100%",
- "&:focus-visible": {
- borderRadius: "18px",
- outline: `2px solid ${green}`,
- outlineOffset: 3,
- },
- }}
- >
- <SocialAvatar
- avatarUrl={comment.avatarUrl}
- name={authorName}
- size={28}
- />
- <Box
- sx={{
- color: textBase,
- fontFamily:
- '"Inter Variable", Inter, sans-serif',
- fontSize: 14,
- fontWeight: 600,
- lineHeight: "20px",
- minWidth: 0,
- overflow: "hidden",
- textOverflow: "ellipsis",
- whiteSpace: "nowrap",
- }}
- >
- {authorName}
- </Box>
- </Box>
- <Box
- aria-hidden
- sx={{
- color: commentsTimestamp,
- flexShrink: 0,
- fontFamily: '"Inter Variable", Inter, sans-serif',
- fontSize: 12,
- fontWeight: 600,
- lineHeight: "16px",
- }}
- >
- Β·
- </Box>
- <Box
- component="time"
- dateTime={timestampDateTime}
- sx={{
- color: commentsTimestamp,
- flexShrink: 0,
- fontFamily: '"Inter Variable", Inter, sans-serif',
- fontSize: 12,
- fontWeight: 600,
- lineHeight: "16px",
- }}
- >
- {timestampLabel}
- </Box>
- </Box>
- )}
- {showOwnTimestamp && (
- <Box
- component="time"
- dateTime={timestampDateTime}
- sx={{
- color: commentsTimestamp,
- fontFamily: '"Inter Variable", Inter, sans-serif',
- fontSize: 12,
- fontWeight: 600,
- lineHeight: "16px",
- mb: "6px",
- mr: "2px",
- }}
- >
- {timestampLabel}
- </Box>
- )}
- <Box
- className={isOwner ? "green-bg" : undefined}
- onContextMenu={handleContextMenu}
- sx={{
- bgcolor: isOwner ? commentsOwnerBubble : commentsSurface,
- borderRadius: bubbleBorderRadius,
- color: textBase,
- display: "block",
- maxWidth: "min(calc(100vw - 72px), 360px)",
- minWidth: 0,
- ml: isOwner ? 0 : "38px",
- overflow: "visible",
- position: "relative",
- px: "16px",
- py: parentComment ? "16px" : "14px",
- textAlign: "left",
- width: "fit-content",
- "&:hover": {
- bgcolor: isOwner ? commentsOwnerBubble : "#343434",
- },
- }}
- >
- {parentComment && (
- <Box
- sx={{
- alignItems: "stretch",
- display: "flex",
- gap: "10px",
- mb: "8px",
- maxWidth: "100%",
- minWidth: 0,
- }}
- >
- <Box
- aria-hidden
- sx={{
- alignSelf: "stretch",
- bgcolor: isOwner
- ? "rgba(255, 255, 255, 0.55)"
- : "#8C8C8C",
- borderRadius: "999px",
- flexShrink: 0,
- width: 3,
- }}
- />
- <Box sx={{ minWidth: 0 }}>
- <Box
- sx={{
- color: "rgba(244, 244, 244, 0.92)",
- fontFamily:
- '"Inter Variable", Inter, sans-serif',
- fontSize: 12,
- fontWeight: 750,
- lineHeight: "18px",
- overflow: "hidden",
- textOverflow: "ellipsis",
- whiteSpace: "nowrap",
- }}
- >
- {parentAuthorName}
- </Box>
- <Box
- sx={{
- color: "rgba(244, 244, 244, 0.82)",
- fontFamily:
- '"Inter Variable", Inter, sans-serif',
- fontSize: 12,
- fontWeight: 500,
- lineHeight: "17px",
- overflow: "hidden",
- textOverflow: "ellipsis",
- whiteSpace: "nowrap",
- }}
- >
- {parentComment.isDeleted
- ? "(deleted)"
- : truncateCommentText(parentComment.text)}
- </Box>
- </Box>
- </Box>
- )}
- <Box
- sx={{
- color: "rgba(244, 244, 244, 0.94)",
- fontFamily: '"Inter Variable", Inter, sans-serif',
- fontSize: 14,
- fontWeight: 600,
- lineHeight: "21px",
- overflowWrap: "anywhere",
- whiteSpace: "pre-wrap",
- }}
- >
- {comment.text}
- </Box>
- {isLiked && (
- <Box
- aria-label="Liked"
- role="img"
- sx={{
- alignItems: "center",
- bgcolor: "#2B2B2B",
- border: `2px solid ${commentsBackground}`,
- borderRadius: "999px",
- bottom: -11,
- boxShadow: "0 4px 10px rgba(0, 0, 0, 0.2)",
- boxSizing: "border-box",
- color: green,
- display: "inline-flex",
- height: 22,
- justifyContent: "center",
- minWidth: 28,
- px: "7px",
- position: "absolute",
- ...(isOwner ? { left: 8 } : { right: 8 }),
- }}
- >
- <HeartIcon filled small />
- </Box>
- )}
- </Box>
- </Box>
- );
-};
-
-interface CommentComposerProps {
- canSend: boolean;
- inputRef?: React.Ref<HTMLTextAreaElement>;
- onChange: (value: string) => void;
- onKeyDown: (event: React.KeyboardEvent) => void;
- onSend: () => void;
- placeholder: string;
- sendPhase: CommentSendPhase;
- sendLabel: string;
- value: string;
-}
-
-const CommentComposer: React.FC<CommentComposerProps> = ({
- canSend,
- inputRef,
- onChange,
- onKeyDown,
- onSend,
- placeholder,
- sendPhase,
- sendLabel,
- value,
-}) => {
- const isSending = sendPhase == "sending";
- const isDone = sendPhase == "done";
- const isMutedStatus = isSending || isDone;
- const isSendButtonActive = canSend || isMutedStatus;
- const sendButtonBg = isMutedStatus
- ? commentsSurfaceHover
- : isSendButtonActive
- ? "#FFFFFF"
- : commentsSurfaceHover;
- const sendButtonColor = isSending
- ? controlIcon
- : isDone
- ? green
- : isSendButtonActive
- ? "#3A3A3A"
- : controlIcon;
- const sendIcon = isSending
- ? Loading03Icon
- : isDone
- ? Tick02Icon
- : Navigation03Icon;
-
- return (
- <Box
- sx={{
- bgcolor: commentsSurface,
- borderRadius: "24px",
- boxSizing: "border-box",
- maxWidth: "100%",
- minWidth: 0,
- position: "relative",
- width: "100%",
- }}
- >
- <Box
- sx={{
- alignItems: "center",
- boxSizing: "border-box",
- display: "flex",
- maxHeight: 300,
- minHeight: 40,
- overflow: "auto",
- p: "1px 54px 3px 16px",
- width: "100%",
- "&::-webkit-scrollbar": { width: "8px" },
- "&::-webkit-scrollbar-track": { background: "transparent" },
- "&::-webkit-scrollbar-thumb": {
- background: "rgba(255, 255, 255, 0.3)",
- borderRadius: "4px",
- },
- "&::-webkit-scrollbar-thumb:hover": {
- background: "rgba(255, 255, 255, 0.5)",
- },
- scrollbarColor: "rgba(255, 255, 255, 0.3) transparent",
- scrollbarWidth: "thin",
- }}
- >
- <TextField
- fullWidth
- multiline
- minRows={1}
- variant="standard"
- placeholder={placeholder}
- value={value}
- onChange={(event) => onChange(event.target.value)}
- onKeyDown={onKeyDown}
- onClick={(event) => event.stopPropagation()}
- inputRef={inputRef}
- slotProps={{
- htmlInput: {
- maxLength: 280,
- readOnly: sendPhase != "idle",
- },
- }}
- sx={{
- "& .MuiInput-root": {
- fontFamily: '"Inter Variable", Inter, sans-serif',
- fontSize: 14,
- fontWeight: 600,
- lineHeight: "21px",
- "&::before, &::after": { display: "none" },
- },
- "& .MuiInputBase-input": {
- color: textBase,
- font: "inherit",
- lineHeight: "21px",
- p: 0,
- "&::placeholder": {
- color: commentsMuted,
- opacity: 1,
- },
- },
- }}
- />
- </Box>
- <Box
- component="button"
- type="button"
- aria-label={isSending ? "Sending" : isDone ? "Sent" : sendLabel}
- disabled={!canSend || sendPhase != "idle"}
- onClick={onSend}
- sx={{
- alignItems: "center",
- bgcolor: sendButtonBg,
- border: 0,
- borderRadius: "50%",
- color: sendButtonColor,
- cursor:
- canSend && sendPhase == "idle" ? "pointer" : "default",
- display: "flex",
- height: 32,
- justifyContent: "center",
- opacity: isSending ? 0.72 : isSendButtonActive ? 1 : 0.42,
- p: 0,
- position: "absolute",
- right: 8,
- bottom: 7,
- transition:
- "background-color 180ms ease, color 180ms ease, opacity 180ms ease, transform 120ms ease",
- width: 32,
- "&:active": {
- transform:
- canSend && sendPhase == "idle"
- ? "scale(0.96)"
- : "none",
- },
- "&:focus-visible": {
- outline: `2px solid ${green}`,
- outlineOffset: 2,
- },
- "&:hover": {
- bgcolor: isMutedStatus
- ? commentsSurfaceHover
- : isSendButtonActive
- ? "#F2F2F2"
- : "rgba(255, 255, 255, 0.14)",
- },
- }}
- >
- <Box
- component="span"
- sx={{
- animation: isSending
- ? `${commentSendSpin} 1s linear infinite`
- : "none",
- display: "flex",
- transform: isSending ? "none" : "translate(-1px, 1px)",
- }}
- >
- <HugeiconsIcon
- icon={sendIcon}
- size={18}
- strokeWidth={1.8}
- />
- </Box>
- </Box>
- </Box>
- );
-};
-
export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
currentUser,
initialScreen = "photo",
@@ -1097,61 +254,22 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
onOpenProfile,
photo,
postActionMode = "like-with-count",
- showPostCaptionInput = false,
}) => {
const {
- showCommentButton: showPhotoCommentButton,
showLikeButton: showPhotoLikeButton,
showLikeCount: showPhotoLikeCount,
} = socialViewerPostActionConfigs[postActionMode];
const canOpenLikes = showPhotoLikeCount;
- const canOpenComments = showPhotoCommentButton;
const resolvedInitialScreen: SocialViewerInitialScreen =
- showPostCaptionInput ||
- (initialScreen == "likes" && !canOpenLikes) ||
- (initialScreen == "comments" && !canOpenComments)
- ? "photo"
- : initialScreen;
+ initialScreen == "likes" && !canOpenLikes ? "photo" : initialScreen;
const [screen, setScreen] = React.useState<SocialViewerInitialScreen>(
resolvedInitialScreen,
);
- const [isIntroVisible, setIsIntroVisible] =
- React.useState(!showPostCaptionInput);
- const [isPostCaptionInputVisible, setIsPostCaptionInputVisible] =
- React.useState(showPostCaptionInput);
- const [isPostCaptionInputExiting, setIsPostCaptionInputExiting] =
- React.useState(false);
- const [arePhotoActionsMounted, setArePhotoActionsMounted] =
- React.useState(!showPostCaptionInput);
- const [arePhotoActionsRevealed, setArePhotoActionsRevealed] =
- React.useState(!showPostCaptionInput);
const [isPhotoLiked, setIsPhotoLiked] = React.useState(false);
- const [isCommentButtonPopping, setIsCommentButtonPopping] =
- React.useState(false);
- const [comments, setComments] = React.useState<SocialComment[]>(() =>
- showPostCaptionInput ? [] : mockComments,
- );
- const [commentText, setCommentText] = React.useState("");
- const [commentSendPhase, setCommentSendPhase] =
- React.useState<CommentSendPhase>("idle");
- const [replyingTo, setReplyingTo] = React.useState<SocialComment | null>(
- null,
- );
- const [likedCommentIDs, setLikedCommentIDs] = React.useState<Set<string>>(
- () => new Set(),
- );
- const [commentContextMenu, setCommentContextMenu] =
- React.useState<CommentContextMenuState | null>(null);
const displayName = firstNameFrom(photo.name);
const dateLabel = formatSocialDate(photo.timestampMs);
const initials = initialsFor(photo.name);
const viewerRootRef = React.useRef<HTMLDivElement | null>(null);
- const commentsContainerRef = React.useRef<HTMLDivElement | null>(null);
- const commentInputRef = React.useRef<HTMLTextAreaElement | null>(null);
- const commentSendTimeoutRef = React.useRef<number | null>(null);
- const captionExitFallbackTimeoutRef = React.useRef<number | null>(null);
- const photoActionsRevealFrameRef = React.useRef<number | null>(null);
- const commentOpenTimeoutRef = React.useRef<number | null>(null);
const likeHoldTimeoutRef = React.useRef<number | null>(null);
const likeHoldStartPointRef = React.useRef<{ x: number; y: number } | null>(
null,
@@ -1159,10 +277,8 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
const ignoreNextLikeClickRef = React.useRef(false);
const suppressNextLikeContextMenuRef = React.useRef(false);
const suppressLikeContextMenuTimeoutRef = React.useRef<number | null>(null);
- const currentUserName = currentUser?.name.trim() || "You";
const photoLikers = React.useMemo(() => {
- const baseLikers = showPostCaptionInput ? [] : mockPhotoLikers;
- if (!isPhotoLiked) return baseLikers;
+ if (!isPhotoLiked) return mockPhotoLikers;
return [
{
@@ -1170,33 +286,11 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
avatarUrl: currentUser?.avatarUrl,
name: "You",
},
- ...baseLikers,
+ ...mockPhotoLikers,
];
- }, [currentUser?.avatarUrl, isPhotoLiked, showPostCaptionInput]);
- const sortedVisibleComments = React.useMemo(
- () =>
- comments
- .filter((comment) => !comment.isDeleted)
- .sort(
- (first, second) =>
- second.createdAtMicros - first.createdAtMicros,
- ),
- [comments],
- );
- const commentCount = sortedVisibleComments.length;
+ }, [currentUser?.avatarUrl, isPhotoLiked]);
const likeCount = photoLikers.length;
- const commentButtonLabel =
- commentCount > 0
- ? `Comment on photo, ${commentCount} ${
- commentCount == 1 ? "comment" : "comments"
- }`
- : "Comment on photo";
const likeCountLabel = `${likeCount} ${likeCount == 1 ? "like" : "likes"}`;
- const isContextCommentLiked = commentContextMenu
- ? likedCommentIDs.has(commentContextMenu.comment.id)
- : false;
- const canSendComment =
- commentText.trim().length > 0 && commentSendPhase == "idle";
const [actionsAnchor, setActionsAnchor] =
React.useState<HTMLElement | null>(null);
const [deleteSheetOpen, setDeleteSheetOpen] = React.useState(false);
@@ -1231,7 +325,6 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
if (!canOpenLikes) return;
clearLikeHoldTimeout();
- setCommentContextMenu(null);
setScreen("likes");
};
@@ -1319,174 +412,12 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
setDeleteActionPhase("busy");
};
- const openComments = () => {
- if (!canOpenComments) return;
- if (isCommentButtonPopping) return;
-
- setIsCommentButtonPopping(true);
- commentOpenTimeoutRef.current = window.setTimeout(() => {
- commentOpenTimeoutRef.current = null;
- setIsCommentButtonPopping(false);
- setScreen("comments");
- window.requestAnimationFrame(() => {
- commentInputRef.current?.focus();
- });
- }, 120);
- };
-
- const closeComments = () => {
- if (commentOpenTimeoutRef.current != null) {
- window.clearTimeout(commentOpenTimeoutRef.current);
- commentOpenTimeoutRef.current = null;
- }
-
- setCommentContextMenu(null);
- setIsCommentButtonPopping(false);
- setScreen("photo");
- };
-
- const openCommentActions = (
- comment: SocialComment,
- anchorEl: HTMLElement,
- ) => {
- setCommentContextMenu({ anchorEl, comment });
- };
-
- const closeCommentActions = () => setCommentContextMenu(null);
-
const openFriendProfile = (friendID: string) => {
- setCommentContextMenu(null);
- onOpenFriend?.(friendID);
- };
-
- const handleCommentAction = (action: "like" | "reply" | "delete") => {
- if (!commentContextMenu) return;
-
- const targetComment = commentContextMenu.comment;
- setCommentContextMenu(null);
-
- switch (action) {
- case "like":
- setLikedCommentIDs((currentIDs) => {
- const nextIDs = new Set(currentIDs);
- if (nextIDs.has(targetComment.id)) {
- nextIDs.delete(targetComment.id);
- } else {
- nextIDs.add(targetComment.id);
- }
- return nextIDs;
- });
- break;
- case "reply":
- setReplyingTo(targetComment);
- break;
- case "delete":
- setComments((currentComments) =>
- currentComments.map((comment) =>
- comment.id == targetComment.id
- ? { ...comment, isDeleted: true }
- : comment,
- ),
- );
- setLikedCommentIDs((currentIDs) => {
- if (!currentIDs.has(targetComment.id)) return currentIDs;
-
- const nextIDs = new Set(currentIDs);
- nextIDs.delete(targetComment.id);
- return nextIDs;
- });
- setReplyingTo((currentReply) =>
- currentReply?.id == targetComment.id ? null : currentReply,
- );
- break;
- }
- };
-
- const completeCaptionComposerExit = () => {
- if (captionExitFallbackTimeoutRef.current != null) {
- window.clearTimeout(captionExitFallbackTimeoutRef.current);
- captionExitFallbackTimeoutRef.current = null;
- }
- if (photoActionsRevealFrameRef.current != null) {
- window.cancelAnimationFrame(photoActionsRevealFrameRef.current);
- photoActionsRevealFrameRef.current = null;
- }
-
- setCommentText("");
- setCommentSendPhase("idle");
- setIsPostCaptionInputVisible(false);
- setIsPostCaptionInputExiting(false);
- setArePhotoActionsMounted(true);
- photoActionsRevealFrameRef.current = window.requestAnimationFrame(
- () => {
- photoActionsRevealFrameRef.current = null;
- setArePhotoActionsRevealed(true);
- },
- );
- };
-
- const sendComment = () => {
- const text = commentText.trim();
- if (!text || commentSendPhase != "idle") return;
-
- const parentCommentID = replyingTo?.id;
- const isCaptionSend = isPostCaptionInputVisible && screen == "photo";
- setCommentSendPhase("sending");
-
- commentSendTimeoutRef.current = window.setTimeout(() => {
- commentSendTimeoutRef.current = null;
- const newComment: SocialComment = {
- author: currentUserName,
- avatarUrl: currentUser?.avatarUrl,
- createdAtMicros: Date.now() * 1000,
- id: `local-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
- isOwner: true,
- parentCommentID,
- text,
- };
-
- setComments((currentComments) => [...currentComments, newComment]);
- setReplyingTo(null);
-
- if (isCaptionSend) {
- setCommentSendPhase("done");
- commentSendTimeoutRef.current = window.setTimeout(() => {
- commentSendTimeoutRef.current = null;
- setIsPostCaptionInputExiting(true);
- captionExitFallbackTimeoutRef.current = window.setTimeout(
- completeCaptionComposerExit,
- captionComposerExitDurationMs + 80,
- );
- }, captionSendDoneDurationMs);
- } else {
- setCommentText("");
- setCommentSendPhase("idle");
- window.setTimeout(() => {
- if (commentsContainerRef.current)
- commentsContainerRef.current.scrollTop = 0;
- }, 0);
- }
- }, commentSendPendingDurationMs);
- };
-
- const handleCommentKeyDown = (event: React.KeyboardEvent) => {
- event.stopPropagation();
- if (event.key != "Enter" || event.shiftKey) return;
-
- event.preventDefault();
- sendComment();
+ onOpenFriend?.(friendID);
};
React.useEffect(
() => () => {
- if (commentSendTimeoutRef.current != null)
- window.clearTimeout(commentSendTimeoutRef.current);
- if (captionExitFallbackTimeoutRef.current != null)
- window.clearTimeout(captionExitFallbackTimeoutRef.current);
- if (photoActionsRevealFrameRef.current != null)
- window.cancelAnimationFrame(photoActionsRevealFrameRef.current);
- if (commentOpenTimeoutRef.current != null)
- window.clearTimeout(commentOpenTimeoutRef.current);
if (likeHoldTimeoutRef.current != null)
window.clearTimeout(likeHoldTimeoutRef.current);
if (suppressLikeContextMenuTimeoutRef.current != null)
@@ -1519,33 +450,6 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
);
}, []);
- React.useEffect(() => {
- if (replyingTo) commentInputRef.current?.focus();
- }, [replyingTo]);
-
- React.useEffect(() => {
- if (
- !isIntroVisible ||
- !isPostCaptionInputVisible ||
- isPostCaptionInputExiting ||
- screen != "photo"
- )
- return;
-
- commentInputRef.current?.focus();
- }, [
- isIntroVisible,
- isPostCaptionInputExiting,
- isPostCaptionInputVisible,
- screen,
- ]);
-
- React.useEffect(() => {
- if (screen != "comments") return;
-
- commentInputRef.current?.focus();
- }, [screen]);
-
React.useEffect(() => {
if (!deleteActionPhase) return;
@@ -1588,7 +492,6 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
let disposed = false;
let closedByReact = false;
let pswp: PhotoSwipe | undefined;
- let introAnimationFrameID: number | undefined;
void import("photoswipe").then(({ default: PhotoSwipeClass }) => {
if (disposed || !viewerRootRef.current) return;
@@ -1641,19 +544,11 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
if (!closedByReact) onClose();
});
pswp.init();
-
- if (showPostCaptionInput) {
- introAnimationFrameID = window.requestAnimationFrame(() => {
- if (!disposed) setIsIntroVisible(true);
- });
- }
});
return () => {
disposed = true;
closedByReact = true;
- if (introAnimationFrameID != undefined)
- window.cancelAnimationFrame(introAnimationFrameID);
pswp?.destroy();
};
}, [
@@ -1663,7 +558,6 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
photo.imageUrl,
photo.name,
photo.width,
- showPostCaptionInput,
]);
React.useEffect(() => {
@@ -1681,14 +575,6 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
if (deleteSheetOpen) return;
if (event.key != "Escape") return;
- if (commentContextMenu) {
- closeCommentActions();
- return;
- }
- if (screen == "comments") {
- closeComments();
- return;
- }
if (screen == "likes") {
closeLikes();
return;
@@ -1699,7 +585,7 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
window.addEventListener("keydown", closeOnEscape);
return () => window.removeEventListener("keydown", closeOnEscape);
- }, [closeLikes, commentContextMenu, deleteSheetOpen, onClose, screen]);
+ }, [closeLikes, deleteSheetOpen, onClose, screen]);
return (
<Box
@@ -1727,24 +613,6 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
: undefined,
width: "100%",
zIndex: 1300,
- "& .pswp-social-viewer": {
- opacity: isIntroVisible ? 1 : 0,
- transform: isIntroVisible ? "scale(1)" : "scale(0.985)",
- transformOrigin: "center center",
- transition: showPostCaptionInput
- ? `opacity ${viewerIntroTransition}, transform ${viewerIntroTransition}`
- : "none",
- willChange: showPostCaptionInput
- ? "opacity, transform"
- : "auto",
- },
- "& [data-social-viewer-chrome='true']": {
- opacity: isIntroVisible ? 1 : 0,
- transition: showPostCaptionInput
- ? `opacity ${viewerIntroTransition}`
- : "none",
- willChange: showPostCaptionInput ? "opacity" : "auto",
- },
}}
>
<Box
@@ -2097,21 +965,15 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
zIndex: 1,
}}
/>
- {arePhotoActionsMounted && showPhotoLikeButton && (
+ {showPhotoLikeButton && (
<Box
data-social-viewer-bottom="true"
sx={{
bottom: "16px",
display: "flex",
gap: "10px",
- opacity:
- isIntroVisible && arePhotoActionsRevealed ? 1 : 0,
- pointerEvents: arePhotoActionsRevealed
- ? "auto"
- : "none",
position: "fixed",
right: "16px",
- transition: `opacity ${captionActionsEnterDurationMs}ms cubic-bezier(0.2, 0, 0, 1)`,
zIndex: 2,
}}
>
@@ -2166,85 +1028,12 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
</Box>
)}
</Box>
- {showPhotoCommentButton && (
- <Box
- component="button"
- type="button"
- aria-label={commentButtonLabel}
- onClick={openComments}
- sx={{
- ...viewerActionButtonSx,
- position: "relative",
- transform: isCommentButtonPopping
- ? "scale(0.96)"
- : "scale(1)",
- }}
- >
- <HugeiconsIcon
- icon={Comment01Icon}
- size={26}
- strokeWidth={1.8}
- />
- {commentCount > 0 && (
- <Box aria-hidden sx={viewerCountBadgeSx}>
- {commentCount}
- </Box>
- )}
- </Box>
- )}
- </Box>
- )}
- {isPostCaptionInputVisible && screen == "photo" && (
- <Box
- data-social-viewer-bottom="true"
- onTransitionEnd={(event) => {
- if (
- event.target != event.currentTarget ||
- event.propertyName != "opacity" ||
- !isPostCaptionInputExiting
- )
- return;
-
- completeCaptionComposerExit();
- }}
- sx={{
- bgcolor: "transparent",
- bottom: 0,
- boxSizing: "border-box",
- left: 0,
- maxWidth: "100%",
- opacity:
- isIntroVisible && !isPostCaptionInputExiting
- ? 1
- : 0,
- p: "0 14px max(12px, env(safe-area-inset-bottom))",
- pointerEvents: isPostCaptionInputExiting
- ? "none"
- : "auto",
- position: "fixed",
- right: 0,
- transition: `opacity ${captionComposerExitDurationMs}ms cubic-bezier(0.4, 0, 0.2, 1)`,
- width: "100%",
- zIndex: 2,
- }}
- >
- <CommentComposer
- canSend={canSendComment}
- inputRef={commentInputRef}
- onChange={setCommentText}
- onKeyDown={handleCommentKeyDown}
- onSend={sendComment}
- placeholder="Add a caption..."
- sendPhase={commentSendPhase}
- sendLabel="Send caption"
- value={commentText}
- />
</Box>
)}
{screen == "likes" && canOpenLikes && (
<Box
sx={{
- bgcolor: commentsBackground,
+ bgcolor: viewerPanelBackground,
boxSizing: "border-box",
color: textBase,
display: "flex",
@@ -2339,7 +1128,7 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
<Box
sx={{
alignItems: "center",
- color: commentsMuted,
+ color: viewerPanelMuted,
display: "flex",
flex: "1 1 auto",
fontFamily:
@@ -2467,414 +1256,6 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
</Box>
</Box>
)}
- {screen == "comments" && canOpenComments && (
- <Box
- sx={{
- bgcolor: commentsBackground,
- boxSizing: "border-box",
- color: textBase,
- display: "flex",
- flexDirection: "column",
- inset: 0,
- maxWidth: "100vw",
- overflow: "hidden",
- overflowX: "hidden",
- position: "fixed",
- width: "100%",
- zIndex: 3,
- }}
- >
- {commentContextMenu && (
- <Box
- aria-hidden
- onClick={closeCommentActions}
- sx={{
- bgcolor: "rgba(0, 0, 0, 0.6)",
- inset: 0,
- position: "absolute",
- zIndex: 1,
- }}
- />
- )}
- <Box
- component="header"
- sx={{
- alignItems: "center",
- boxSizing: "border-box",
- display: "grid",
- flexShrink: 0,
- gridTemplateColumns: "1fr 40px",
- minHeight: 56,
- px: "16px",
- width: "100%",
- }}
- >
- <Box
- component="h1"
- sx={{
- color: textBase,
- fontFamily:
- '"Inter Variable", Inter, sans-serif',
- fontSize: 16,
- fontWeight: 750,
- lineHeight: "20px",
- m: 0,
- }}
- >
- {commentCount}{" "}
- {commentCount == 1 ? "comment" : "comments"}
- </Box>
- <Box
- component="button"
- type="button"
- aria-label="Close comments"
- onClick={closeComments}
- sx={{
- alignItems: "center",
- bgcolor: "transparent",
- border: 0,
- borderRadius: "50%",
- color: controlIcon,
- cursor: "pointer",
- display: "flex",
- height: 28,
- justifyContent: "center",
- justifySelf: "flex-end",
- p: 0,
- width: 28,
- "&:focus-visible": {
- outline: `2px solid ${green}`,
- outlineOffset: 2,
- },
- "&:hover": {
- bgcolor: "transparent",
- color: textBase,
- },
- }}
- >
- <HugeiconsIcon
- icon={Cancel01Icon}
- size={18}
- strokeWidth={1.8}
- />
- </Box>
- </Box>
- <Box
- component="ol"
- ref={commentsContainerRef}
- sx={{
- boxSizing: "border-box",
- display: "flex",
- flex: "1 1 auto",
- flexDirection: "column-reverse",
- m: 0,
- maxWidth: "100%",
- minHeight: 0,
- overflowX: "hidden",
- overflowY: "auto",
- p: "14px 16px 18px",
- width: "100%",
- }}
- >
- {sortedVisibleComments.length == 0 ? (
- <Box
- sx={{
- alignItems: "center",
- color: commentsMuted,
- display: "flex",
- flex: "1 1 auto",
- fontFamily:
- '"Inter Variable", Inter, sans-serif',
- fontSize: 14,
- fontWeight: 600,
- justifyContent: "center",
- lineHeight: "20px",
- minHeight: 0,
- }}
- >
- No comments yet
- </Box>
- ) : (
- sortedVisibleComments.map((comment, index) => {
- const prevComment =
- sortedVisibleComments[index + 1];
- const nextComment =
- sortedVisibleComments[index - 1];
- const isSameSequenceAsPrev =
- prevComment &&
- sameCommentAuthor(prevComment, comment) &&
- comment.createdAtMicros -
- prevComment.createdAtMicros <=
- commentGroupTimeThresholdMicros;
- const isSameSequenceAsNext =
- nextComment &&
- sameCommentAuthor(nextComment, comment) &&
- nextComment.createdAtMicros -
- comment.createdAtMicros <=
- commentGroupTimeThresholdMicros;
- const isFirstInSequence = !isSameSequenceAsPrev;
- const isLastInSequence = !isSameSequenceAsNext;
- const authorFriendID = comment.isOwner
- ? undefined
- : friendIDForPersonName(comment.author);
-
- return (
- <CommentItem
- key={comment.id}
- comment={comment}
- isHighlighted={
- commentContextMenu?.comment.id ==
- comment.id
- }
- isLastInSequence={isLastInSequence}
- isLiked={likedCommentIDs.has(
- comment.id,
- )}
- onOpenActions={openCommentActions}
- onOpenAuthorProfile={
- authorFriendID && onOpenFriend
- ? () =>
- openFriendProfile(
- authorFriendID,
- )
- : undefined
- }
- parentComment={getParentComment(
- comment.parentCommentID,
- comments,
- )}
- showHeader={
- isFirstInSequence &&
- !comment.isOwner
- }
- showOwnTimestamp={
- isFirstInSequence &&
- Boolean(comment.isOwner)
- }
- />
- );
- })
- )}
- </Box>
- <Menu
- anchorEl={commentContextMenu?.anchorEl}
- open={Boolean(commentContextMenu)}
- onClose={closeCommentActions}
- anchorOrigin={{
- horizontal: "right",
- vertical: "bottom",
- }}
- transformOrigin={{
- horizontal: "right",
- vertical: "top",
- }}
- slotProps={{
- paper: {
- sx: {
- bgcolor: "#1E1E1E",
- borderRadius: "16px",
- boxShadow:
- "0 14px 40px rgba(0, 0, 0, 0.22)",
- minWidth: 132,
- p: "4px",
- },
- },
- list: { sx: { p: 0 } },
- }}
- >
- <MenuItem
- disableRipple
- onClick={() => handleCommentAction("like")}
- sx={{
- borderRadius: "12px",
- color: textBase,
- gap: "8px",
- minHeight: 38,
- px: "8px",
- py: "7px",
- "&:hover": {
- bgcolor: "rgba(255, 255, 255, 0.1)",
- },
- }}
- >
- <HeartIcon small />
- <Box
- sx={{
- fontFamily:
- '"Inter Variable", Inter, sans-serif',
- fontSize: 13,
- fontWeight: 650,
- lineHeight: "18px",
- }}
- >
- {isContextCommentLiked ? "Unlike" : "Like"}
- </Box>
- </MenuItem>
- <MenuItem
- disableRipple
- onClick={() => handleCommentAction("reply")}
- sx={{
- borderRadius: "12px",
- color: textBase,
- gap: "8px",
- minHeight: 38,
- px: "8px",
- py: "7px",
- "&:hover": {
- bgcolor: "rgba(255, 255, 255, 0.1)",
- },
- }}
- >
- <ReplyIcon />
- <Box
- sx={{
- fontFamily:
- '"Inter Variable", Inter, sans-serif',
- fontSize: 13,
- fontWeight: 650,
- lineHeight: "18px",
- }}
- >
- Reply
- </Box>
- </MenuItem>
- {commentContextMenu?.comment.isOwner && (
- <MenuItem
- disableRipple
- onClick={() => handleCommentAction("delete")}
- sx={{
- borderRadius: "12px",
- color: dangerColor,
- gap: "8px",
- minHeight: 38,
- px: "8px",
- py: "7px",
- "&:hover": {
- bgcolor: "rgba(246, 58, 58, 0.14)",
- },
- }}
- >
- <DeleteIcon />
- <Box
- sx={{
- fontFamily:
- '"Inter Variable", Inter, sans-serif',
- fontSize: 13,
- fontWeight: 650,
- lineHeight: "18px",
- }}
- >
- Delete
- </Box>
- </MenuItem>
- )}
- </Menu>
- <Box
- sx={{
- bgcolor: commentsBackground,
- boxSizing: "border-box",
- flexShrink: 0,
- maxWidth: "100%",
- p: "18px 14px max(12px, env(safe-area-inset-bottom))",
- width: "100%",
- }}
- >
- {replyingTo && (
- <Box
- sx={{
- bgcolor: "rgba(255, 255, 255, 0.08)",
- borderLeft: "3px solid #8C8C8C",
- borderRadius: "12px",
- boxSizing: "border-box",
- display: "grid",
- gap: "8px",
- gridTemplateColumns: "minmax(0, 1fr) 24px",
- mb: "10px",
- p: "9px 8px 9px 12px",
- width: "100%",
- }}
- >
- <Box sx={{ minWidth: 0 }}>
- <Box
- sx={{
- color: commentsTimestamp,
- fontFamily:
- '"Inter Variable", Inter, sans-serif',
- fontSize: 12,
- fontWeight: 650,
- lineHeight: "16px",
- }}
- >
- Replying to{" "}
- {replyingTo.isOwner
- ? "yourself"
- : firstNameFrom(replyingTo.author)}
- </Box>
- <Box
- sx={{
- color: textBase,
- fontFamily:
- '"Inter Variable", Inter, sans-serif',
- fontSize: 13,
- fontWeight: 600,
- lineHeight: "18px",
- overflow: "hidden",
- textOverflow: "ellipsis",
- whiteSpace: "nowrap",
- }}
- >
- {truncateCommentText(replyingTo.text)}
- </Box>
- </Box>
- <Box
- component="button"
- type="button"
- aria-label="Cancel reply"
- onClick={() => {
- setReplyingTo(null);
- commentInputRef.current?.focus();
- }}
- sx={{
- alignItems: "center",
- bgcolor: "transparent",
- border: 0,
- borderRadius: "50%",
- color: controlIcon,
- cursor: "pointer",
- display: "flex",
- height: 24,
- justifyContent: "center",
- p: 0,
- width: 24,
- "&:focus-visible": {
- outline: `2px solid ${green}`,
- outlineOffset: 2,
- },
- "&:hover": { color: textBase },
- }}
- >
- <HugeiconsIcon
- icon={Cancel01Icon}
- size={16}
- strokeWidth={1.8}
- />
- </Box>
- </Box>
- )}
- <CommentComposer
- canSend={canSendComment}
- inputRef={commentInputRef}
- onChange={setCommentText}
- onKeyDown={handleCommentKeyDown}
- onSend={sendComment}
- placeholder="Add a comment..."
- sendPhase={commentSendPhase}
- sendLabel="Send comment"
- value={commentText}
- />
- </Box>
- </Box>
- )}
{onDeletePost && (
<ConfirmationActionSheet
appearance="dark"
diff --git a/web/apps/social/src/screens/HomeScreen.tsx b/web/apps/social/src/screens/HomeScreen.tsx
index 3732e16513..964ad39efa 100644
--- a/web/apps/social/src/screens/HomeScreen.tsx
+++ b/web/apps/social/src/screens/HomeScreen.tsx
@@ -64,7 +64,6 @@ const sampleFeedItems = [
friendID: "aparna-bhatnagar",
imageUrl: "/images/sample-feed-1.jpg",
likeCount: 18,
- commentCount: 6,
name: "Aparna Bhatnagar",
timestampMs: minutesAgo(22),
},
@@ -74,7 +73,6 @@ const sampleFeedItems = [
friendID: "mira-sen",
imageUrl: "/images/sample-feed-portrait-2.jpg",
likeCount: 24,
- commentCount: 9,
name: "Mira Sen",
timestampMs: hoursAgo(2),
},
@@ -84,7 +82,6 @@ const sampleFeedItems = [
friendID: "mira-sen",
imageUrl: "/images/sample-feed-2.jpg",
likeCount: 15,
- commentCount: 4,
name: "Mira Sen",
timestampMs: hoursAgo(3),
},
@@ -94,7 +91,6 @@ const sampleFeedItems = [
friendID: "nikhil-rao",
imageUrl: "/images/sample-feed-portrait-3.jpg",
likeCount: 31,
- commentCount: 12,
name: "Nikhil Rao",
timestampMs: hoursAgo(7),
},
@@ -104,7 +100,6 @@ const sampleFeedItems = [
friendID: "nikhil-rao",
imageUrl: "/images/sample-feed-3.jpg",
likeCount: 11,
- commentCount: 3,
name: "Nikhil Rao",
timestampMs: daysAgo(1),
},
@@ -114,7 +109,6 @@ const sampleFeedItems = [
friendID: "riya-kapoor",
imageUrl: "/images/sample-feed-portrait-4.jpg",
likeCount: 28,
- commentCount: 8,
name: "Riya Kapoor",
timestampMs: daysAgo(1) - 3 * 60 * 60 * 1000,
},
@@ -124,7 +118,6 @@ const sampleFeedItems = [
friendID: "riya-kapoor",
imageUrl: "/images/sample-feed-4.jpg",
likeCount: 16,
- commentCount: 5,
name: "Riya Kapoor",
timestampMs: daysAgo(2),
},
@@ -134,7 +127,6 @@ const sampleFeedItems = [
friendID: "aparna-bhatnagar",
imageUrl: "/images/sample-feed-portrait-1.jpg",
likeCount: 22,
- commentCount: 7,
name: "Aparna Bhatnagar",
timestampMs: daysAgo(3),
},
@@ -144,7 +136,6 @@ const sampleFeedItems = [
friendID: "aparna-bhatnagar",
imageUrl: "/images/sample-feed-5.jpg",
likeCount: 13,
- commentCount: 4,
name: "Aparna Bhatnagar",
timestampMs: daysAgo(4),
},
@@ -154,7 +145,6 @@ const sampleFeedItems = [
friendID: "mira-sen",
imageUrl: "/images/sample-feed-portrait-5.jpg",
likeCount: 36,
- commentCount: 14,
name: "Mira Sen",
timestampMs: daysAgo(6),
},
@@ -164,7 +154,6 @@ const sampleFeedItems = [
friendID: "mira-sen",
imageUrl: "/images/sample-feed-6.jpg",
likeCount: 19,
- commentCount: 6,
name: "Mira Sen",
timestampMs: daysAgo(8),
},
@@ -174,7 +163,6 @@ const sampleFeedItems = [
friendID: "nikhil-rao",
imageUrl: "/images/sample-feed-portrait-6.jpg",
likeCount: 27,
- commentCount: 10,
name: "Nikhil Rao",
timestampMs: daysAgo(12),
},
@@ -184,7 +172,6 @@ const sampleFeedItems = [
friendID: "nikhil-rao",
imageUrl: "/images/sample-feed-2.jpg",
likeCount: 43,
- commentCount: 17,
name: "Nikhil Rao",
timestampMs: new Date(new Date().getFullYear() - 1, 10, 18).getTime(),
},
@@ -208,7 +195,6 @@ interface SelectedHomeViewer {
localObjectUrl?: string;
photo: SocialViewerPhoto;
postActionMode?: SocialViewerPostActionMode;
- showPostCaptionInput?: boolean;
}
interface FeedItemProps {
@@ -497,9 +483,7 @@ const FeedItem: React.FC<FeedItemProps> = ({
outline: `2px solid ${green}`,
outlineOffset: 2,
},
- "&:hover": {
- bgcolor: feedLikeActionBackgroundHover,
- },
+ "&:hover": { bgcolor: feedLikeActionBackgroundHover },
}}
>
<HugeiconsIcon
@@ -632,7 +616,6 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
localObjectUrl: localPost.objectUrl,
photo: localPost.photo,
postActionMode: "like-with-count",
- showPostCaptionInput: true,
};
setPostActionPhase("posting");
@@ -1018,9 +1001,6 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
postActionMode={
selectedViewer.postActionMode ?? "like-with-count"
}
- showPostCaptionInput={
- selectedViewer.showPostCaptionInput
- }
onClose={closeSelectedPhoto}
onOpenFriend={
onOpenFriend
diff --git a/web/apps/social/src/screens/ProfileScreen.tsx b/web/apps/social/src/screens/ProfileScreen.tsx
index e510e9f265..eadbe66596 100644
--- a/web/apps/social/src/screens/ProfileScreen.tsx
+++ b/web/apps/social/src/screens/ProfileScreen.tsx
@@ -15,8 +15,8 @@ import {
} from "components/SocialActionFeedback";
import {
SocialFileViewer,
- type SocialViewerPostActionMode,
type SocialViewerPhoto,
+ type SocialViewerPostActionMode,
} from "components/SocialFileViewer";
import { EnteLogo } from "ente-base/components/EnteLogo";
import React, { useState } from "react";
@@ -149,7 +149,6 @@ interface SelectedProfilePost {
id: string;
localObjectUrl?: string;
photo: SocialViewerPhoto;
- showPostCaptionInput?: boolean;
}
interface PostMasonryTile {
@@ -353,7 +352,6 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
id: `local-${localPost.photo.timestampMs}`,
localObjectUrl: localPost.objectUrl,
photo: localPost.photo,
- showPostCaptionInput: true,
};
setPostActionPhase("posting");
@@ -1274,7 +1272,6 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
}}
photo={selectedPost.photo}
postActionMode={selectedPostActionMode}
- showPostCaptionInput={selectedPost.showPostCaptionInput}
onClose={closeSelectedPost}
onDeletePost={
isOwnerProfile ? deleteSelectedPost : undefined