π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Remove public album code from shared gallery
Anand Baburajan786e9ca20ca4
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 6ed981f9bf..8d27d3936d 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -25,6 +25,7 @@ import {getAndClearIsFirstLogin,getAndClearJustSignedUp,} from "ente-accounts/services/accounts-db";+import { processPendingAlbumJoin } from "ente-accounts/services/join-album";import { stashRedirect } from "ente-accounts/services/redirect";import { isSessionInvalid } from "ente-accounts/services/session";import { ensureLocalUser } from "ente-accounts/services/user";@@ -41,6 +42,7 @@ import { useIsSmallWidth } from "ente-base/components/utils/hooks";import { useModalVisibility } from "ente-base/components/utils/modal";import { useBaseContext } from "ente-base/context";import { subscribeMainWindowFocus } from "ente-base/electron";+import { hasPendingAlbumToJoin } from "ente-base/join-album";import log from "ente-base/log";import {clearSessionStorage,@@ -56,10 +58,6 @@ import { type FileViewerInitialSidebar } from "ente-gallery/components/viewer/Fiimport { CollectionSubType, type Collection } from "ente-media/collection";import { type EnteFile } from "ente-media/file";import { ItemVisibility } from "ente-media/file-metadata";-import {- hasPendingAlbumToJoin,- processPendingAlbumJoin,-} from "ente-new/albums/services/join-album";import { AssignPersonDialog } from "ente-new/photos/components/AssignPersonDialog";import {CollectionSelector,diff --git a/web/apps/photos/src/pages/index.tsx b/web/apps/photos/src/pages/index.tsxindex 3d9f3768cf..02ca2cc24a 100644--- a/web/apps/photos/src/pages/index.tsx+++ b/web/apps/photos/src/pages/index.tsx@@ -7,6 +7,10 @@ import { EnteLogo } from "ente-base/components/EnteLogo";import { ActivityIndicator } from "ente-base/components/mui/ActivityIndicator";import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";import { useBaseContext } from "ente-base/context";+import {+ JOIN_ALBUM_CONTEXT_KEY,+ type JoinAlbumContext,+} from "ente-base/join-album";import log from "ente-base/log";import { customAPIHost } from "ente-base/origins";import {@@ -15,10 +19,6 @@ import {} from "ente-base/session";import { savedAuthToken } from "ente-base/token";import { canAccessIndexedDB } from "ente-gallery/services/files-db";-import {- JOIN_ALBUM_CONTEXT_KEY,- type JoinAlbumContext,-} from "ente-new/albums/services/join-album";import { DevSettings } from "ente-new/photos/components/DevSettings";import { t } from "i18next";import { useRouter } from "next/router";diff --git a/web/packages/accounts-rs/components/LoginContents.tsx b/web/packages/accounts-rs/components/LoginContents.tsxindex 64f803a8d9..aa29f820d5 100644--- a/web/packages/accounts-rs/components/LoginContents.tsx+++ b/web/packages/accounts-rs/components/LoginContents.tsx@@ -10,8 +10,8 @@ import { appName } from "ente-base/app";import { LinkButton } from "ente-base/components/LinkButton";import { LoadingButton } from "ente-base/components/mui/LoadingButton";import { HTTPError } from "ente-base/http";+import { JOIN_ALBUM_CONTEXT_KEY } from "ente-base/join-album";import log from "ente-base/log";-import { JOIN_ALBUM_CONTEXT_KEY } from "ente-new/albums/services/join-album";import { useFormik } from "formik";import { t } from "i18next";import { useRouter } from "next/router";diff --git a/web/packages/accounts-rs/components/SignUpContents.tsx b/web/packages/accounts-rs/components/SignUpContents.tsxindex e61c0a58ac..47793ef19f 100644--- a/web/packages/accounts-rs/components/SignUpContents.tsx+++ b/web/packages/accounts-rs/components/SignUpContents.tsx@@ -34,8 +34,8 @@ import { LinkButton } from "ente-base/components/LinkButton";import { LoadingButton } from "ente-base/components/mui/LoadingButton";import { ShowHidePasswordInputAdornment } from "ente-base/components/mui/PasswordInputAdornment";import { isMuseumHTTPError } from "ente-base/http";+import { JOIN_ALBUM_CONTEXT_KEY } from "ente-base/join-album";import log from "ente-base/log";-import { JOIN_ALBUM_CONTEXT_KEY } from "ente-new/albums/services/join-album";import { useFormik } from "formik";import { t } from "i18next";import type { NextRouter } from "next/router";diff --git a/web/packages/accounts/components/LoginContents.tsx b/web/packages/accounts/components/LoginContents.tsxindex 738e012336..cecd3c0e6e 100644--- a/web/packages/accounts/components/LoginContents.tsx+++ b/web/packages/accounts/components/LoginContents.tsx@@ -10,8 +10,8 @@ import { appName } from "ente-base/app";import { LinkButton } from "ente-base/components/LinkButton";import { LoadingButton } from "ente-base/components/mui/LoadingButton";import { HTTPError } from "ente-base/http";+import { JOIN_ALBUM_CONTEXT_KEY } from "ente-base/join-album";import log from "ente-base/log";-import { JOIN_ALBUM_CONTEXT_KEY } from "ente-new/albums/services/join-album";import { useFormik } from "formik";import { t } from "i18next";import { useRouter } from "next/router";diff --git a/web/packages/accounts/components/SignUpContents.tsx b/web/packages/accounts/components/SignUpContents.tsxindex 56188ee303..3674820b07 100644--- a/web/packages/accounts/components/SignUpContents.tsx+++ b/web/packages/accounts/components/SignUpContents.tsx@@ -33,9 +33,9 @@ import { LoadingButton } from "ente-base/components/mui/LoadingButton";import { ShowHidePasswordInputAdornment } from "ente-base/components/mui/PasswordInputAdornment";import { deriveKeyInsufficientMemoryErrorMessage } from "ente-base/crypto/types";import { isMuseumHTTPError } from "ente-base/http";+import { JOIN_ALBUM_CONTEXT_KEY } from "ente-base/join-album";import log from "ente-base/log";import { saveMasterKeyInSessionAndSafeStore } from "ente-base/session";-import { JOIN_ALBUM_CONTEXT_KEY } from "ente-new/albums/services/join-album";import { useFormik } from "formik";import { t } from "i18next";import type { NextRouter } from "next/router";diff --git a/web/packages/new/albums/services/join-album.ts b/web/packages/accounts/services/join-album.tssimilarity index 69%rename from web/packages/new/albums/services/join-album.tsrename to web/packages/accounts/services/join-album.tsindex 4b6d2ca3fd..8ea37e6a3a 100644--- a/web/packages/new/albums/services/join-album.ts+++ b/web/packages/accounts/services/join-album.ts@@ -1,6 +1,10 @@import { savedKeyAttributes } from "ente-accounts/services/accounts-db";import { boxSeal, fromB64 } from "ente-base/crypto";import { authenticatedRequestHeaders } from "ente-base/http";+import {+ clearJoinAlbumContext,+ getJoinAlbumContext,+} from "ente-base/join-album";import log from "ente-base/log";import { apiURL } from "ente-base/origins";@@ -12,61 +16,7 @@ import { apiURL } from "ente-base/origins";*/const collectionKeyBytes = 32;-/**- * Service for handling the join album flow for public collections.- * This manages the process of joining a public album, including:- * - Storing album context before authentication- * - Auto-joining after authentication- * - Cleaning up stored context- */--export const JOIN_ALBUM_CONTEXT_KEY = "ente_join_album_context";--export interface JoinAlbumContext {- accessToken: string;- collectionKey: string; // Base64 encoded collection key for API calls- collectionKeyHash: string; // Original hash value from URL (base58 or hex)- collectionID: number;- accessTokenJWT?: string; // JWT token for password-protected albums-}--/**- * Retrieve stored album context after authentication.- * Checks sessionStorage for the stored context.- */-export const getJoinAlbumContext = (): JoinAlbumContext | null => {- const stored = sessionStorage.getItem(JOIN_ALBUM_CONTEXT_KEY);- if (!stored) {- return null;- }-- try {- const context = JSON.parse(stored) as JoinAlbumContext;- return context;- } catch {- return null;- }-};--/**- * Clear the stored album context after successful join or timeout.- */-export const clearJoinAlbumContext = () => {- sessionStorage.removeItem(JOIN_ALBUM_CONTEXT_KEY);-};--/**- * Check if there's a pending album to join.- */-export const hasPendingAlbumToJoin = (): boolean => {- return getJoinAlbumContext() !== null;-};--/**- * Join a public album by sending the encrypted collection key to the server.- * This adds the album to the user's collection.- */-export const joinPublicAlbum = async (+const joinPublicAlbum = async (accessToken: string,collectionID: number,encryptedKey: string,@@ -79,7 +29,7 @@ export const joinPublicAlbum = async ("Content-Type": "application/json",...authHeaders,"X-Auth-Access-Token": accessToken,- ...(accessTokenJWT && { "X-Auth-Access-Token-JWT": accessTokenJWT }), // Include JWT for password-protected albums+ ...(accessTokenJWT && { "X-Auth-Access-Token-JWT": accessTokenJWT }),};const response = await fetch(url, {diff --git a/web/packages/base/join-album.ts b/web/packages/base/join-album.tsnew file mode 100644index 0000000000..2ee1c0bd76--- /dev/null+++ b/web/packages/base/join-album.ts@@ -0,0 +1,40 @@+export const JOIN_ALBUM_CONTEXT_KEY = "ente_join_album_context";++export interface JoinAlbumContext {+ accessToken: string;+ collectionKey: string; // Base64 encoded collection key for API calls+ collectionKeyHash: string; // Original hash value from URL (base58 or hex)+ collectionID: number;+ accessTokenJWT?: string; // JWT token for password-protected albums+}++/**+ * Retrieve stored album context after authentication.+ * Checks sessionStorage for the stored context.+ */+export const getJoinAlbumContext = (): JoinAlbumContext | null => {+ const stored = sessionStorage.getItem(JOIN_ALBUM_CONTEXT_KEY);+ if (!stored) {+ return null;+ }++ try {+ return JSON.parse(stored) as JoinAlbumContext;+ } catch {+ return null;+ }+};++/**+ * Clear the stored album context after successful join or timeout.+ */+export const clearJoinAlbumContext = () => {+ sessionStorage.removeItem(JOIN_ALBUM_CONTEXT_KEY);+};++/**+ * Check if there's a pending album to join.+ */+export const hasPendingAlbumToJoin = (): boolean => {+ return getJoinAlbumContext() !== null;+};diff --git a/web/packages/gallery/components/viewer/AddNameModal.tsx b/web/packages/gallery/components/viewer/AddNameModal.tsxdeleted file mode 100644index a67c3d5844..0000000000--- a/web/packages/gallery/components/viewer/AddNameModal.tsx+++ /dev/null@@ -1,404 +0,0 @@-import CloseIcon from "@mui/icons-material/Close";-import {- Box,- Button,- Dialog,- IconButton,- styled,- TextField,- Typography,-} from "@mui/material";-import { type ModalVisibilityProps } from "ente-base/components/utils/modal";-import { t } from "i18next";-import React, { useState } from "react";--// =============================================================================-// Icons-// =============================================================================--const LikeIllustration: React.FC = () => (- <svg- width="126"- height="121"- viewBox="0 0 126 121"- fill="none"- xmlns="http://www.w3.org/2000/svg"- >- <path- d="M84.7129 23.0781C96.7222 23.0784 105.29 32.8476 105.29 44.499C105.29 53.3449 99.7258 62.2116 93.4453 69.4932C87.0622 76.8936 79.4391 83.2238 74.3574 87.0557C69.973 90.3616 64.031 90.3614 59.6465 87.0557C54.5648 83.2238 46.9408 76.8937 40.5576 69.4932C34.2771 62.2116 28.7129 53.3449 28.7129 44.499C28.713 32.8474 37.2813 23.0781 49.291 23.0781C54.9545 23.0782 60.4297 24.9062 67.001 30.9004C73.5726 24.9056 79.0491 23.0781 84.7129 23.0781Z"- fill="#08C225"- stroke="#232323"- strokeWidth="5.73358"- strokeLinecap="round"- strokeLinejoin="round"- />- <mask- id="mask0_add_name"- style={{ maskType: "alpha" }}- maskUnits="userSpaceOnUse"- x="31"- y="25"- width="72"- height="62"- >- <path- d="M61.3721 84.7662C51.3787 77.2306 31.5801 60.0026 31.5801 44.4993C31.5801 34.2522 39.0372 25.9453 49.2909 25.9453C54.6041 25.9453 59.9173 27.7313 67.0016 34.8751C74.086 27.7313 79.3992 25.9453 84.7124 25.9453C94.9659 25.9453 102.423 34.2522 102.423 44.4993C102.423 60.0026 82.6247 77.2306 72.6312 84.7662C69.2683 87.3019 64.735 87.3019 61.3721 84.7662Z"- fill="#08C225"- />- </mask>- <g mask="url(#mask0_add_name)">- <path- d="M47.5975 41.0431C46.8515 39.3306 47.9859 37.1849 50.1312 36.2504C52.2765 35.316 54.6203 35.9467 55.3662 37.6591C56.1121 39.3716 54.9777 41.5173 52.8324 42.4518C50.6872 43.3862 48.3434 42.7555 47.5975 41.0431Z"- fill="white"- />- <path- d="M44.5677 45.0545C44.3136 44.4712 44.7025 43.7391 45.4364 43.4194C46.1704 43.0997 46.9713 43.3135 47.2254 43.8968C47.4795 44.4802 47.0906 45.2123 46.3567 45.532C45.6227 45.8517 44.8218 45.6379 44.5677 45.0545Z"- fill="white"- />- <path- d="M102.994 32.271C101.622 55.1395 78.9821 78.0073 50.9683 82.581C49.2531 88.2982 42.3926 93.7861 42.3926 95.1582C42.3926 96.5303 48.1097 107.926 50.9683 113.453L89.8447 101.447L115 66.5725C113.094 57.9969 106.196 31.3563 102.994 32.271Z"- fill="#46A030"- />- <path- d="M59.7039 28.2666C34.9591 23.1218 29.8137 47.7054 32.6723 55.1377L23.1143 51.7074C21.3992 47.3243 18.1976 37.9863 19.1123 35.6995C20.0271 33.4126 22.1615 16.833 23.1143 8.829L55.1302 3.68359L96.8651 13.9744C97.6274 18.1664 98.4659 26.8936 95.7217 28.2666C80.2855 22.5506 66.5644 33.9826 66.5644 33.4109C66.5644 32.9535 68.4701 30.5523 69.423 29.4089C66.3738 29.0281 60.1612 28.2666 59.7039 28.2666Z"- fill="white"- />- </g>- <path- d="M20.9639 58.8477C14.9399 61.182 10.9104 66.0874 11.263 71.48C10.9104 66.0874 6.28324 61.7544 -9.80907e-05 60.2184C6.02383 57.884 10.0533 52.9787 9.70073 47.5861C10.0533 52.9787 14.6805 57.3117 20.9639 58.8477Z"- fill="#08C225"- />- <path- d="M119.579 91.9746C111.591 92.7003 105.114 97.1692 103.689 103.722C105.114 97.1692 101.077 90.4145 94.1117 86.438C102.099 85.7122 108.576 81.2434 110.001 74.6902C108.576 81.2434 112.613 87.9981 119.579 91.9746Z"- fill="#08C225"- />- <path- d="M112.728 9.21189C108.334 9.91374 104.912 12.6353 104.37 16.3181C104.912 12.6353 102.421 9.04853 98.4114 7.10627C102.806 6.40442 106.228 3.68284 106.77 7.55054e-05C106.228 3.68284 108.719 7.26962 112.728 9.21189Z"- fill="#08C225"- />- </svg>-);--const CommentIllustration: React.FC = () => (- <svg- width="146"- height="104"- viewBox="0 0 146 104"- fill="none"- xmlns="http://www.w3.org/2000/svg"- >- <path- d="M62.4161 23.9825C69.5416 21.6377 77.2027 21.4587 84.4301 23.4677C91.6577 25.4768 98.1278 29.5846 103.021 35.2705C107.914 40.9564 111.011 47.9656 111.921 55.4117C112.83 62.8579 111.511 70.4066 108.131 77.1033C104.75 83.8 99.4603 89.3444 92.929 93.0344C86.3977 96.7244 78.9186 98.3952 71.438 97.8347C65.5124 97.3907 59.9955 95.6061 55.1766 92.7912L36.6137 95.1736C35.7803 95.2805 34.9485 94.962 34.4004 94.3252C33.8523 93.6882 33.6604 92.8183 33.8903 92.0101L39.0115 74.0065C36.9468 68.823 36.0051 63.1057 36.4493 57.1772C37.0098 49.6966 39.7764 42.5499 44.3984 36.6414C49.0204 30.733 55.2905 26.3274 62.4161 23.9825Z"- fill="#08C225"- stroke="#232323"- strokeWidth="5"- strokeLinecap="round"- strokeLinejoin="round"- />- <mask- id="mask0_add_name_comment"- style={{ maskType: "alpha" }}- maskUnits="userSpaceOnUse"- x="36"- y="24"- width="74"- height="72"- >- <path- d="M71.6249 95.341C78.6125 95.8645 85.5985 94.3043 91.6993 90.8575C97.8002 87.4107 102.742 82.2321 105.899 75.9768C109.057 69.7214 110.289 62.6702 109.439 55.7147C108.59 48.7592 105.696 42.2119 101.126 36.9007C96.5551 31.5895 90.512 27.753 83.7608 25.8763C77.0096 23.9996 69.8535 24.167 63.1974 26.3573C56.5414 28.5477 50.6843 32.6626 46.3669 38.1817C42.0494 43.7008 39.4656 50.3762 38.942 57.3639C38.5044 63.2051 39.5049 68.8185 41.6537 73.8587L36.2949 92.6938L55.7183 90.2015C60.382 93.0774 65.7876 94.9037 71.6249 95.341Z"- fill="#08C225"- />- </mask>- <g mask="url(#mask0_add_name_comment)">- <path- d="M90.785 29.2779C55.9844 19.5648 41.0889 44.5028 37.9912 58.186L34.2834 72.1186C32.1784 72.553 27.1513 72.4724 23.883 68.6747C19.7976 63.9275 7.9607 55.936 8.75491 45.336C9.54911 34.736 9.85699 18.7723 10.8726 17.072C11.6851 15.7117 48.8217 4.51972 67.2885 -0.90625L123.817 3.32912C127.307 16.0258 125.586 38.991 90.785 29.2779Z"- fill="white"- />- <path- d="M68.1126 36.8926C67.7871 34.8769 69.5702 32.9123 72.0953 32.5044C74.6204 32.0966 76.9313 33.4 77.2568 35.4157C77.5824 37.4313 75.7993 39.3959 73.2742 39.8038C70.7491 40.2116 68.4382 38.9082 68.1126 36.8926Z"- fill="white"- />- <path- d="M63.6068 40.3106C63.4959 39.624 64.1063 38.9542 64.9702 38.8147C65.834 38.6752 66.6242 39.1187 66.7351 39.8054C66.846 40.492 66.2356 41.1618 65.3718 41.3013C64.5079 41.4408 63.7177 40.9973 63.6068 40.3106Z"- fill="white"- />- <path- d="M35.0516 84.4974C50.0736 86.3458 84.2825 85.3953 100.941 66.8061C117.601 48.217 131.472 23.1618 129.517 33.958C128.008 42.824 108.57 103.778 97.3574 108.665C83.3409 114.774 55.5151 127.853 46.4893 128.205C37.4635 128.557 25.3268 115.992 24.0509 114.477C22.775 112.962 24.2879 103.196 26.2494 99.9921C27.959 97.1997 26.5317 91.4899 26.2742 90.6394C26.2622 90.6323 26.2542 90.6209 26.2503 90.6048C26.2237 90.4942 26.2362 90.514 26.2742 90.6394C26.7756 90.9343 34.2208 83.5106 35.0516 84.4974Z"- fill="#24B41F"- />- <path- d="M63.1172 64.2407C65.5626 64.2849 67.581 62.3384 67.6253 59.8929C67.6695 57.4475 65.723 55.4291 63.2775 55.3849C60.8321 55.3406 58.8137 57.2871 58.7694 59.7326C58.7252 62.1781 60.6717 64.1964 63.1172 64.2407Z"- fill="#232323"- />- <path- d="M75.293 64.4555C77.7384 64.4998 79.7568 62.5532 79.801 60.1078C79.8453 57.6623 77.8988 55.644 75.4533 55.5997C73.0078 55.5554 70.9895 57.502 70.9452 59.9474C70.901 62.3929 72.8475 64.4112 75.293 64.4555Z"- fill="#232323"- />- <path- d="M87.4707 64.6821C89.9162 64.7263 91.9345 62.7798 91.9788 60.3343C92.023 57.8889 90.0765 55.8705 87.631 55.8263C85.1856 55.782 83.1672 57.7285 83.123 60.174C83.0787 62.6195 85.0252 64.6378 87.4707 64.6821Z"- fill="#232323"- />- </g>- <path- d="M20.1099 75.4512C14.3314 77.6905 10.4661 82.396 10.8043 87.5689C10.4661 82.396 6.02735 78.2395 0 76.7661C5.77852 74.5268 9.64385 69.8213 9.30562 64.6484C9.64385 69.8213 14.0826 73.9778 20.1099 75.4512Z"- fill="#08C225"- />- <path- d="M145.699 62.5334C138.037 63.2295 131.824 67.5164 130.457 73.8026C131.824 67.5164 127.951 61.0368 121.27 57.2223C128.932 56.5261 135.145 52.2393 136.512 45.9531C135.145 52.2393 139.017 58.7188 145.699 62.5334Z"- fill="#08C225"- />- <path- d="M51.1361 8.83653C46.9208 9.50979 43.6377 12.1205 43.1181 15.6532C43.6377 12.1205 41.2488 8.67983 37.4023 6.81669C41.6176 6.14343 44.9007 3.53273 45.4202 0C44.9007 3.53273 47.2896 6.97339 51.1361 8.83653Z"- fill="#08C225"- />- </svg>-);--// =============================================================================-// Types-// =============================================================================--export interface AddNameModalProps extends ModalVisibilityProps {- /**- * Called when user submits their name.- */- onSubmit: (name: string) => void;- /**- * The type of action being performed (like or comment).- * Defaults to 'like'.- */- actionType?: "like" | "comment";- /**- * Called after the modal's exit animation completes.- */- onExited?: () => void;-}--/**- * Modal dialog for adding a name when liking or commenting on a photo anonymously.- */-export const AddNameModal: React.FC<AddNameModalProps> = ({- open,- onClose,- onSubmit,- actionType = "like",- onExited,-}) => {- const [name, setName] = useState("");- const isComment = actionType === "comment";-- const handleSubmit = () => {- if (name.trim()) {- onSubmit(name.trim());- setName("");- }- };-- const handleClose = () => {- setName("");- onClose();- };-- return (- <StyledDialog- open={open}- onClose={handleClose}- slotProps={{ transition: { onExited } }}- >- <DialogWrapper>- <CloseButton onClick={handleClose}>- <CloseIcon sx={{ fontSize: 20 }} />- </CloseButton>-- <ContentContainer>- <IllustrationWrapper>- {isComment ? (- <CommentIllustration />- ) : (- <LikeIllustration />- )}- </IllustrationWrapper>-- <TitleSection>- <Title>{t("set_your_name")}</Title>- <Subtitle>{t("set_your_name_subtitle")}</Subtitle>- </TitleSection>-- <StyledTextField- fullWidth- placeholder={t("name_placeholder")}- variant="standard"- value={name}- onChange={(e) => setName(e.target.value)}- onKeyDown={(e) => {- if (e.key === "Enter") {- e.preventDefault();- handleSubmit();- }- }}- autoFocus- slotProps={{ htmlInput: { maxLength: 50 } }}- />-- <SubmitButton- variant="contained"- fullWidth- onClick={handleSubmit}- hasName={!!name.trim()}- >- {isComment ? t("set_name") : t("set_name_and_like")}- </SubmitButton>- </ContentContainer>- </DialogWrapper>- </StyledDialog>- );-};--// =============================================================================-// Styled Components-// =============================================================================--const StyledDialog = styled(Dialog)(({ theme }) => ({- "& .MuiDialog-paper": {- width: 381,- maxWidth: "calc(100% - 32px)",- borderRadius: 28,- backgroundColor: "#fff",- padding: 0,- margin: 16,- overflow: "visible",- boxShadow: "none",- border: "1px solid #E0E0E0",- ...theme.applyStyles("dark", {- backgroundColor: "#1b1b1b",- border: "1px solid rgba(255, 255, 255, 0.18)",- }),- },- "& .MuiBackdrop-root": { backgroundColor: "rgba(0, 0, 0, 0.5)" },-}));--const DialogWrapper = styled(Box)(() => ({- position: "relative",- padding: "48px 16px 16px 16px",-}));--const CloseButton = styled(IconButton)(({ theme }) => ({- position: "absolute",- top: 11,- right: 12,- backgroundColor: "#FAFAFA",- color: "#000",- padding: 10,- "&:hover": { backgroundColor: "#F0F0F0" },- ...theme.applyStyles("dark", {- backgroundColor: "rgba(255, 255, 255, 0.12)",- color: "#fff",- "&:hover": { backgroundColor: "rgba(255, 255, 255, 0.16)" },- }),-}));--const ContentContainer = styled(Box)(() => ({- display: "flex",- flexDirection: "column",- alignItems: "center",- gap: 16,-}));--const IllustrationWrapper = styled(Box)(() => ({- display: "flex",- justifyContent: "center",- alignItems: "center",- marginBottom: 8,-}));--const TitleSection = styled(Box)(() => ({- display: "flex",- flexDirection: "column",- alignItems: "center",- gap: 9,- textAlign: "center",- marginBottom: 8,-}));--const Title = styled(Typography)(({ theme }) => ({- fontWeight: 600,- fontSize: 24,- lineHeight: "28px",- letterSpacing: "-0.48px",- color: "#000",- ...theme.applyStyles("dark", { color: "#fff" }),-}));--const Subtitle = styled(Typography)(({ theme }) => ({- fontWeight: 500,- fontSize: 14,- lineHeight: "20px",- color: "#666666",- maxWidth: 295,- ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.7)" }),-}));--const StyledTextField = styled(TextField)(({ theme }) => ({- "& .MuiInput-root": {- height: 54,- backgroundColor: "#FAFAFA",- borderRadius: 12,- "&::before": { borderBottom: "1px solid #E0E0E0" },- "&::after": { borderBottom: "2px solid #08C225" },- "&:hover:not(.Mui-disabled)::before": {- borderBottom: "1px solid #BDBDBD",- },- },- "& .MuiInputBase-input": {- padding: "0 16px",- height: "100%",- boxSizing: "border-box",- fontSize: 16,- color: "#000",- "&::placeholder": { color: "#999", opacity: 1 },- },- ...theme.applyStyles("dark", {- "& .MuiInput-root": {- backgroundColor: "rgba(255, 255, 255, 0.08)",- "&::before": { borderBottom: "1px solid rgba(255, 255, 255, 0.3)" },- "&:hover:not(.Mui-disabled)::before": {- borderBottom: "1px solid rgba(255, 255, 255, 0.5)",- },- },- "& .MuiInputBase-input": {- color: "#fff",- "&::placeholder": { color: "rgba(255, 255, 255, 0.5)" },- },- }),-}));--const SubmitButton = styled(Button)<{ hasName: boolean }>(- ({ hasName, theme }) => ({- display: "flex",- padding: "20px 16px",- justifyContent: "center",- alignItems: "center",- gap: 8,- flex: "1 0 0",- borderRadius: 20,- backgroundColor: hasName ? "#08C225" : "rgba(0, 0, 0, 0.04)",- fontSize: 16,- fontWeight: 500,- textTransform: "none",- color: hasName ? "#fff" : "#999",- boxShadow: "none",- "&:hover": {- backgroundColor: hasName ? "#07A820" : "rgba(0, 0, 0, 0.08)",- boxShadow: "none",- },- ...theme.applyStyles("dark", {- backgroundColor: hasName ? "#08C225" : "rgba(255, 255, 255, 0.08)",- color: hasName ? "#fff" : "rgba(255, 255, 255, 0.5)",- "&:hover": {- backgroundColor: hasName- ? "#07A820"- : "rgba(255, 255, 255, 0.12)",- },- }),- }),-);diff --git a/web/packages/gallery/components/viewer/CommentsSidebar.tsx b/web/packages/gallery/components/viewer/CommentsSidebar.tsxindex c26add8e5a..b4850dfe3f 100644--- a/web/packages/gallery/components/viewer/CommentsSidebar.tsx+++ b/web/packages/gallery/components/viewer/CommentsSidebar.tsx@@ -13,22 +13,10 @@ import {Typography,} from "@mui/material";import { type ModalVisibilityProps } from "ente-base/components/utils/modal";-import type { PublicAlbumsCredentials } from "ente-base/http";import log from "ente-base/log";-import { isOfficialAlbumsApp } from "ente-base/origins";import { downloadManager } from "ente-gallery/services/download";import { getAvatarColor } from "ente-gallery/utils/avatar-colors";import type { EnteFile } from "ente-media/file";-import {- addPublicComment,- deletePublicComment,-} from "ente-new/albums/services/public-comment";-import {- addPublicCommentReaction,- createAnonIdentity,- deletePublicReaction,- getStoredAnonIdentity,-} from "ente-new/albums/services/public-reaction";import { getCollectionByID } from "ente-new/photos/services/collection";import type { CollectionSummaries } from "ente-new/photos/services/collection-summary";import {@@ -49,9 +37,6 @@ import React, {useRef,useState,} from "react";-import { AddNameModal } from "./AddNameModal";-import { PublicCommentModal } from "./PublicCommentModal";-import { PublicLikeModal } from "./PublicLikeModal";// =============================================================================// Icons@@ -428,30 +413,10 @@ export interface CommentsSidebarProps extends ModalVisibilityProps {* If set, the sidebar will scroll to and highlight this comment.*/highlightCommentID?: string;- /**- * Public album credentials for anonymous commenting.- * Required when viewing a public album (no logged in user).- */- publicAlbumsCredentials?: PublicAlbumsCredentials;- /**- * The decrypted collection key (base64 encoded) for encrypting comments.- * Required when viewing a public album (no logged in user).- */- collectionKey?: string;/*** Map of anonymous user ID to decrypted user name.*/anonUserNames?: Map<string, string>;- /**- * Called when user clicks "Join album to like" in the public like modal.- * Should trigger the join album flow (with mobile deep link fallback).- */- onJoinAlbum?: () => void;- /**- * Whether the "Join album" option is enabled for this public link.- * When false, the "Join album and like/comment" buttons will be hidden.- */- enableJoin?: boolean;}/**@@ -479,11 +444,7 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({onCommentReactionAdded,onCommentReactionDeleted,highlightCommentID,- publicAlbumsCredentials,- collectionKey,anonUserNames,- onJoinAlbum,- enableJoin = true,}) => {const [commentText, setCommentText] = useState("");const [replyingTo, setReplyingTo] = useState<Comment | null>(null);@@ -492,15 +453,6 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({);const [collectionDropdownOpen, setCollectionDropdownOpen] = useState(false);const [comments, setComments] = useState<Comment[]>([]);- const [showPublicCommentModal, setShowPublicCommentModal] = useState(false);- const [showAddNameModal, setShowAddNameModal] = useState(false);- const [showPublicLikeModal, setShowPublicLikeModal] = useState(false);- const [pendingCommentLike, setPendingCommentLike] =- useState<Comment | null>(null);- /** Tracks whether the AddNameModal was triggered by a comment like action */- const [addNameForCommentLike, setAddNameForCommentLike] = useState(false);- /** Tracks whether the user has set up their anonymous identity for commenting */- const [hasAnonIdentity, setHasAnonIdentity] = useState(false);const [loading, setLoading] = useState(false);const [sending, setSending] = useState(false);const hasLoadedRef = useRef(false);@@ -660,26 +612,8 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({return fileNormalCollectionIDs?.get(file.id) ?? [];}, [file, fileNormalCollectionIDs]);- // Check if this is a public album- const isPublicAlbum = isOfficialAlbumsApp || !!publicAlbumsCredentials;-// Build collection info list with comment counts and cover files (shared albums only)const collectionsInfo = useMemo((): CollectionInfo[] => {- // For public albums, use the file's collection directly- if (isPublicAlbum && file) {- return [- {- id: file.collectionID,- name: "Album",- commentCount:- commentsByCollection- .get(file.collectionID)- ?.filter((c) => !c.isDeleted).length ?? 0,- coverFile: file,- },- ];- }-return fileCollectionIDs.filter((collectionID) =>collectionSummaries@@ -698,13 +632,7 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({coverFile: summary?.coverFile,};});- }, [- isPublicAlbum,- file,- fileCollectionIDs,- collectionSummaries,- commentsByCollection,- ]);+ }, [fileCollectionIDs, collectionSummaries, commentsByCollection]);// Collections sorted by comment count (descending) for dropdownconst sortedCollectionsInfo = useMemo(() => {@@ -735,22 +663,9 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({const canDeleteComment = useCallback((comment: Comment): boolean => {// Comment author can always delete their own comment- // For logged-in users, check userIDif (comment.userID === currentUserID) {return true;}- // For anonymous users, check anonUserID- if (selectedCollectionInfo) {- const storedIdentity = getStoredAnonIdentity(- selectedCollectionInfo.id,- );- if (- storedIdentity &&- comment.anonUserID === storedIdentity.anonUserID- ) {- return true;- }- }// Check if user is owner or admin of the selected collectionconst collectionID = selectedCollectionInfo?.id;@@ -804,22 +719,18 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({return currentSelection;}- // Initial selection: find collection with most comments- // Only consider shared collections (non-shared ones won't appear in the UI)- // For public albums, skip the shared check since there's no collectionSummaries+ // Initial selection: find collection with most comments.+ // Only consider shared collections (non-shared ones won't appear in the UI).let maxCount = -1;let bestCollectionID: number | undefined;for (const [collectionID,collectionComments,] of prefetchedComments) {- // Skip non-shared collections (except for public albums)- if (!isPublicAlbum) {- const isShared = collectionSummaries- ?.get(collectionID)- ?.attributes.has("shared");- if (!isShared) continue;- }+ const isShared = collectionSummaries+ ?.get(collectionID)+ ?.attributes.has("shared");+ if (!isShared) continue;const count = collectionComments.filter((c) => !c.isDeleted,@@ -853,7 +764,6 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({hasCollectionContext,activeCollectionID,collectionSummaries,- isPublicAlbum,]);// Load comments when the sidebar opens@@ -871,22 +781,18 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({selectedCollectionID === undefined &&commentsByCollection.size > 0) {- // Find the collection with the most comments- // Only consider shared collections (non-shared ones won't appear in the UI)- // For public albums, skip the shared check since there's no collectionSummaries+ // Find the collection with the most comments.+ // Only consider shared collections (non-shared ones won't appear in the UI).let maxCount = -1;let bestCollectionID: number | undefined;for (const [collectionID,collectionComments,] of commentsByCollection) {- // Skip non-shared collections (except for public albums)- if (!isPublicAlbum) {- const isShared = collectionSummaries- ?.get(collectionID)- ?.attributes.has("shared");- if (!isShared) continue;- }+ const isShared = collectionSummaries+ ?.get(collectionID)+ ?.attributes.has("shared");+ if (!isShared) continue;const count = collectionComments.filter((c) => !c.isDeleted,@@ -906,7 +812,6 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({selectedCollectionID,commentsByCollection,collectionSummaries,- isPublicAlbum,]);// Update displayed comments when selected collection changes (gallery view)@@ -918,16 +823,6 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({}}, [hasCollectionContext, selectedCollectionID, commentsByCollection]);- // Update hasAnonIdentity when collection changes (for public albums)- useEffect(() => {- if (isPublicAlbum && selectedCollectionInfo) {- const storedIdentity = getStoredAnonIdentity(- selectedCollectionInfo.id,- );- setHasAnonIdentity(!!storedIdentity);- }- }, [isPublicAlbum, selectedCollectionInfo]);-// Fetch thumbnails for each collection's cover fileuseEffect(() => {if (!open || collectionsInfo.length === 0) {@@ -983,53 +878,20 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({return;}- // Get stored anon identity for public albums- const storedIdentity = isPublicAlbum- ? getStoredAnonIdentity(selectedCollectionInfo.id)- : undefined;-- // Find comment reactions that are likes from the current user (or anon user)+ // Find comment reactions that are likes from the current user.const newLikedComments = new Map<string, string>();for (const reaction of reactions) {if (reaction.commentID && reaction.reactionType === "green_heart") {- // Check if this is the current user's reaction- const isCurrentUserReaction =- reaction.userID === currentUserID ||- (storedIdentity &&- reaction.anonUserID === storedIdentity.anonUserID);- if (isCurrentUserReaction) {+ if (reaction.userID === currentUserID) {newLikedComments.set(reaction.commentID, reaction.id);}}}setLikedComments(newLikedComments);- }, [- open,- selectedCollectionInfo,- reactionsByCollection,- currentUserID,- isPublicAlbum,- ]);+ }, [open, selectedCollectionInfo, reactionsByCollection, currentUserID]);const handleSend = async () => {if (!commentText.trim() || !file || !selectedCollectionInfo) return;-- // For public albums, check if we already have an anon identity- if (isPublicAlbum) {- const storedIdentity = getStoredAnonIdentity(- selectedCollectionInfo.id,- );- if (storedIdentity && publicAlbumsCredentials && collectionKey) {- // User already has identity, send directly- await sendPublicComment(commentText.trim());- } else {- // Show modal to choose anonymous or join album- setShowPublicCommentModal(true);- }- return;- }-- // For authenticated users, send via APIconst text = commentText.trim();const collectionID = selectedCollectionInfo.id;@@ -1084,203 +946,8 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({}};- /**- * Send a comment to the public album API using stored anonymous identity.- */- const sendPublicComment = async (text: string) => {- if (- !file ||- !selectedCollectionInfo ||- !publicAlbumsCredentials ||- !collectionKey- ) {- return;- }-- const collectionID = selectedCollectionInfo.id;- const storedIdentity = getStoredAnonIdentity(collectionID);- if (!storedIdentity) {- log.error("No stored identity for public comment");- return;- }-- setSending(true);- try {- const newCommentID = await addPublicComment(- publicAlbumsCredentials,- collectionID,- file.id,- text,- collectionKey,- replyingTo?.id,- storedIdentity,- );-- // Add the new comment to local state- const newComment: Comment = {- id: newCommentID,- collectionID,- fileID: file.id,- text,- parentCommentID: replyingTo?.id,- isDeleted: false,- userID: 0, // Anonymous user- anonUserID: storedIdentity.anonUserID,- createdAt: Date.now() * 1000, // Microseconds to match server format- updatedAt: Date.now() * 1000,- };- setComments((prev) => [...prev, newComment]);- setCommentsByCollection((prev) => {- const next = new Map(prev);- const existing = next.get(collectionID) ?? [];- next.set(collectionID, [...existing, newComment]);- return next;- });-- setCommentText("");- setReplyingTo(null);-- // Notify parent to update its comments state- onCommentAdded?.(newComment);-- // Scroll to bottom after adding comment- setTimeout(() => {- if (commentsContainerRef.current) {- commentsContainerRef.current.scrollTop = 0;- }- }, 0);- } catch (e) {- log.error("Failed to add public comment", e);- } finally {- setSending(false);- }- };-- const handleCommentAnonymously = () => {- setShowPublicCommentModal(false);- setShowAddNameModal(true);- };-- const handleJoinAlbumToComment = () => {- setShowPublicCommentModal(false);- onJoinAlbum?.();- };-- const handleLikeAnonymously = () => {- setShowPublicLikeModal(false);- setAddNameForCommentLike(true);- setShowAddNameModal(true);- };-- const handleJoinAlbumToLike = () => {- setShowPublicLikeModal(false);- setPendingCommentLike(null);- onJoinAlbum?.();- };-- const handleNameSubmit = async (name: string) => {- setShowAddNameModal(false);-- if (- !selectedCollectionInfo ||- !publicAlbumsCredentials ||- !collectionKey- ) {- setPendingCommentLike(null);- setAddNameForCommentLike(false);- return;- }-- const collectionID = selectedCollectionInfo.id;-- // Check if this is for a comment like action- if (addNameForCommentLike && pendingCommentLike) {- try {- // Create anonymous identity with the provided name- const identity = await createAnonIdentity(- publicAlbumsCredentials,- collectionID,- name,- collectionKey,- );-- // Now like the comment using the new identity- const reactionID = await addPublicCommentReaction(- publicAlbumsCredentials,- collectionID,- pendingCommentLike.id,- "green_heart",- collectionKey,- identity,- pendingCommentLike.fileID,- );- const newReaction: UnifiedReaction = {- id: reactionID,- collectionID,- commentID: pendingCommentLike.id,- reactionType: "green_heart",- userID: 0,- anonUserID: identity.anonUserID,- isDeleted: false,- createdAt: Date.now() * 1000,- updatedAt: Date.now() * 1000,- };- setLikedComments((prev) => {- const next = new Map(prev);- next.set(pendingCommentLike.id, reactionID);- return next;- });- setReactionsByCollection((prev) => {- const next = new Map(prev);- const reactions = next.get(collectionID) ?? [];- next.set(collectionID, [...reactions, newReaction]);- return next;- });- onCommentReactionAdded?.(newReaction);- setHasAnonIdentity(true);- } catch (e) {- log.error("Failed to create identity and like comment", e);- } finally {- setPendingCommentLike(null);- setAddNameForCommentLike(false);- }- return;- }-- // Handle comment action - just create identity, don't send comment- // User will type and send the comment afterwards- try {- await createAnonIdentity(- publicAlbumsCredentials,- collectionID,- name,- collectionKey,- );- // Identity created, user can now type and send comments- setHasAnonIdentity(true);- } catch (e) {- log.error("Failed to create anonymous identity", e);- }- };-- // Check if user needs to set up identity before commenting (public album without identity)- const needsIdentityToComment =- isPublicAlbum && selectedCollectionInfo && !hasAnonIdentity;-const handleReply = (commentToReply: Comment) => {setReplyingTo(commentToReply);-- // For public albums, check if we have an identity- if (needsIdentityToComment) {- setShowPublicCommentModal(true);- }- };-- // Handler for clicking the comment input area on public albums- const handleInputClick = () => {- if (needsIdentityToComment) {- setShowPublicCommentModal(true);- }};// Handler for keydown: Enter to send, Shift+Enter for new line@@ -1326,145 +993,55 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({const existingReactionID = likedComments.get(targetComment.id);try {- if (isPublicAlbum) {- // Public album - use public APIs- if (!publicAlbumsCredentials || !collectionKey) {- log.error(- "Missing credentials for public album comment like",- );- return;- }-- const storedIdentity = getStoredAnonIdentity(collectionID);- if (!storedIdentity) {- // No identity - show modal to set name- setPendingCommentLike(targetComment);- setShowPublicLikeModal(true);- return;- }+ const collection = await getCollectionByID(collectionID);- if (existingReactionID) {- // Unlike - delete the reaction- await deletePublicReaction(- publicAlbumsCredentials,- collectionID,- existingReactionID,- storedIdentity,- );- setLikedComments((prev) => {- const next = new Map(prev);- next.delete(targetComment.id);- return next;- });- setReactionsByCollection((prev) => {- const next = new Map(prev);- const reactions = next.get(collectionID) ?? [];- next.set(- collectionID,- reactions.filter(- (r) => r.id !== existingReactionID,- ),- );- return next;- });- onCommentReactionDeleted?.(- collectionID,- existingReactionID,- );- } else {- // Like - add a reaction- const reactionID = await addPublicCommentReaction(- publicAlbumsCredentials,+ if (existingReactionID) {+ await deleteReaction(existingReactionID);+ setLikedComments((prev) => {+ const next = new Map(prev);+ next.delete(targetComment.id);+ return next;+ });+ setReactionsByCollection((prev) => {+ const next = new Map(prev);+ const reactions = next.get(collectionID) ?? [];+ next.set(collectionID,- targetComment.id,- "green_heart",- collectionKey,- storedIdentity,- targetComment.fileID,+ reactions.filter((r) => r.id !== existingReactionID),);- const newReaction: UnifiedReaction = {- id: reactionID,- collectionID,- commentID: targetComment.id,- reactionType: "green_heart",- userID: 0,- anonUserID: storedIdentity.anonUserID,- isDeleted: false,- createdAt: Date.now() * 1000,- updatedAt: Date.now() * 1000,- };- setLikedComments((prev) => {- const next = new Map(prev);- next.set(targetComment.id, reactionID);- return next;- });- setReactionsByCollection((prev) => {- const next = new Map(prev);- const reactions = next.get(collectionID) ?? [];- next.set(collectionID, [...reactions, newReaction]);- return next;- });- onCommentReactionAdded?.(newReaction);- }+ return next;+ });+ onCommentReactionDeleted?.(collectionID, existingReactionID);} else {- // Authenticated user - use regular APIs- const collection = await getCollectionByID(collectionID);-- if (existingReactionID) {- // Unlike - delete the reaction- await deleteReaction(existingReactionID);- setLikedComments((prev) => {- const next = new Map(prev);- next.delete(targetComment.id);- return next;- });- setReactionsByCollection((prev) => {- const next = new Map(prev);- const reactions = next.get(collectionID) ?? [];- next.set(- collectionID,- reactions.filter(- (r) => r.id !== existingReactionID,- ),- );- return next;- });- onCommentReactionDeleted?.(- collectionID,- existingReactionID,- );- } else {- // Like - add a reaction- const reactionID = await addCommentReaction(- collectionID,- targetComment.id,- "green_heart",- collection.key,- targetComment.fileID,- );- const newReaction: UnifiedReaction = {- id: reactionID,- collectionID,- commentID: targetComment.id,- reactionType: "green_heart",- userID: currentUserID ?? 0,- isDeleted: false,- createdAt: Date.now() * 1000,- updatedAt: Date.now() * 1000,- };- setLikedComments((prev) => {- const next = new Map(prev);- next.set(targetComment.id, reactionID);- return next;- });- setReactionsByCollection((prev) => {- const next = new Map(prev);- const reactions = next.get(collectionID) ?? [];- next.set(collectionID, [...reactions, newReaction]);- return next;- });- onCommentReactionAdded?.(newReaction);- }+ const reactionID = await addCommentReaction(+ collectionID,+ targetComment.id,+ "green_heart",+ collection.key,+ targetComment.fileID,+ );+ const newReaction: UnifiedReaction = {+ id: reactionID,+ collectionID,+ commentID: targetComment.id,+ reactionType: "green_heart",+ userID: currentUserID ?? 0,+ isDeleted: false,+ createdAt: Date.now() * 1000,+ updatedAt: Date.now() * 1000,+ };+ setLikedComments((prev) => {+ const next = new Map(prev);+ next.set(targetComment.id, reactionID);+ return next;+ });+ setReactionsByCollection((prev) => {+ const next = new Map(prev);+ const reactions = next.get(collectionID) ?? [];+ next.set(collectionID, [...reactions, newReaction]);+ return next;+ });+ onCommentReactionAdded?.(newReaction);}} catch (e) {log.error("Failed to toggle comment like", e);@@ -1487,27 +1064,7 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({break;case "delete":try {- // Use public API for anonymous users in public albums- if (isPublicAlbum && publicAlbumsCredentials) {- const storedIdentity = getStoredAnonIdentity(- selectedCollectionInfo.id,- );- if (storedIdentity) {- await deletePublicComment(- publicAlbumsCredentials,- targetComment.collectionID,- targetComment.id,- storedIdentity,- );- } else {- log.error(- "No stored identity for public comment delete",- );- return;- }- } else {- await deleteComment(targetComment.id);- }+ await deleteComment(targetComment.id);// Update local statesetComments((prev) =>@@ -1699,21 +1256,8 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({<EmptyMessage>{t("no_comments_yet")}</EmptyMessage>) : (sortedComments.map((comment, index) => {- // Check if this is the current user's comment- // For logged-in users, check userID- // For anonymous users, check anonUserID against stored identity- const storedIdentity = selectedCollectionInfo- ? getStoredAnonIdentity(- selectedCollectionInfo.id,- )- : undefined;- const isCurrentAnonUser = !!(- storedIdentity &&- comment.anonUserID === storedIdentity.anonUserID- );const commentIsOwn =- comment.userID === currentUserID ||- isCurrentAnonUser;+ comment.userID === currentUserID;// With column-reverse, visual order is reversed from array order// Visual "above" = higher index, visual "below" = lower index@@ -1820,10 +1364,7 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({!showOwnTimestamp &&commentIsOwn &&!!prevComment &&- prevComment.userID !==- currentUserID &&- prevComment.anonUserID !==- storedIdentity?.anonUserID+ prevComment.userID !== currentUserID}isLastOwn={isLastInSequence}isHighlighted={@@ -1865,9 +1406,6 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({anonUserNames={anonUserNames}- currentAnonUserID={- storedIdentity?.anonUserID- }/>)}<CommentText@@ -1953,21 +1491,7 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({>Replying to{" "}{(() => {- // Check for anonymous userif (replyingTo.anonUserID) {- const storedIdentity =- selectedCollectionInfo- ? getStoredAnonIdentity(- selectedCollectionInfo.id,- )- : undefined;- if (- storedIdentity &&- replyingTo.anonUserID ===- storedIdentity.anonUserID- ) {- return t("yourself");- }return (anonUserNames?.get(replyingTo.anonUserID,@@ -2024,34 +1548,12 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({</ReplyingToContent></ReplyingToBar>)}- <InputWrapper- onClick={handleInputClick}- sx={- needsIdentityToComment- ? (theme) => ({- cursor: "pointer",- borderRadius: "20px",- overflow: "hidden",- transition: "background-color 0.15s ease",- "&:hover": {- backgroundColor:- "rgba(0, 0, 0, 0.04)",- ...theme.applyStyles("dark", {- backgroundColor:- "rgba(255, 255, 255, 0.08)",- }),- },- "& .MuiInputBase-root, & .MuiInputBase-input":- { cursor: "pointer" },- })- : undefined- }- >+ <InputWrapper><StyledTextFieldfullWidthmultilineminRows={1}- autoFocus={!needsIdentityToComment}+ autoFocusplaceholder={t("say_something_nice_placeholder")}variant="standard"value={commentText}@@ -2073,39 +1575,6 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({</SendButton></InputContainer></DrawerContentWrapper>-- {/* Public album modals */}- <PublicCommentModal- open={showPublicCommentModal}- onClose={() => setShowPublicCommentModal(false)}- onCommentAnonymously={handleCommentAnonymously}- onJoinAlbumToComment={handleJoinAlbumToComment}- enableJoin={enableJoin}- />- <PublicLikeModal- open={showPublicLikeModal}- onClose={() => {- setShowPublicLikeModal(false);- setPendingCommentLike(null);- }}- onLikeAnonymously={handleLikeAnonymously}- onJoinAlbumToLike={handleJoinAlbumToLike}- enableJoin={enableJoin}- />- <AddNameModal- open={showAddNameModal}- onClose={() => {- setShowAddNameModal(false);- setPendingCommentLike(null);- }}- onExited={() => {- // Reset actionType after modal has fully closed to avoid- // visual glitch of icon changing during exit animation- setAddNameForCommentLike(false);- }}- onSubmit={handleNameSubmit}- actionType={addNameForCommentLike ? "like" : "comment"}- /></SidebarDrawer>);};diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsxindex 8197acbf59..b14d32e898 100644--- a/web/packages/gallery/components/viewer/FileViewer.tsx+++ b/web/packages/gallery/components/viewer/FileViewer.tsx@@ -32,10 +32,8 @@ import { useInterval, useIsSmallWidth } from "ente-base/components/utils/hooks";import { type ModalVisibilityProps } from "ente-base/components/utils/modal";import { useBaseContext } from "ente-base/context";import { lowercaseExtension } from "ente-base/file-name";-import type { PublicAlbumsCredentials } from "ente-base/http";import { formattedListJoin, ut } from "ente-base/i18n";import log from "ente-base/log";-import { isOfficialAlbumsApp } from "ente-base/origins";import {FileInfo,type FileInfoExif,@@ -46,15 +44,6 @@ import { fileFileName, ItemVisibility } from "ente-media/file-metadata";import { FileType } from "ente-media/file-type";import type { EnteFile } from "ente-media/file.js";import { isHEICExtension, needsJPEGConversion } from "ente-media/formats";-import {- addPublicReaction,- createAnonIdentity,- deletePublicReaction,- getPublicAnonProfiles,- getPublicParticipantsMaskedEmails,- getPublicSocialDiff,- getStoredAnonIdentity,-} from "ente-new/albums/services/public-reaction";import {ImageEditorOverlay,type ImageEditorOverlayProps,@@ -76,7 +65,6 @@ import React, {useRef,useState,} from "react";-import { AddNameModal } from "./AddNameModal";import { CommentsSidebar } from "./CommentsSidebar";import {fileInfoExifForFile,@@ -92,7 +80,6 @@ import {resetMoreMenuButtonOnMenuClose,type FileViewerPhotoSwipeDelegate,} from "./photoswipe";-import { PublicLikeModal } from "./PublicLikeModal";const fileViewerBackStateKey = "__enteFileViewerBackState";@@ -176,8 +163,8 @@ export type FileViewerProps = ModalVisibilityProps & {* - If we're running in the context of the photos app, then this should be* set to the currently logged in user.*- * - If we're running in the context of the public albums app, then this- * should not be set.+ * - If we're running in a viewer without account context, then this should+ * not be set.** See: [Note: Gallery children can assume user]*/@@ -354,17 +341,11 @@ export type FileViewerProps = ModalVisibilityProps & {* The ID of the currently active collection, if any (e.g., when viewing an album).*/activeCollectionID?: number;- /**- * Public album credentials for anonymous reactions/comments.- * Required when viewing a public album (no logged in user).- */- publicAlbumsCredentials?: PublicAlbumsCredentials;/*** If set, overrides whether browser back should be consumed to close the* viewer.*- * By default this is enabled in public album context, and disabled- * otherwise.+ * By default this is disabled.*/shouldCloseOnBrowserBack?: boolean;/**@@ -372,19 +353,7 @@ export type FileViewerProps = ModalVisibilityProps & {*/disableEscapeClose?: boolean;/**- * The decrypted collection key (base64 encoded) for encrypting reactions.- * Required when viewing a public album (no logged in user).- */- collectionKey?: string;- /**- * Called when user clicks "Join album to like" in the public like modal.- * Should trigger the join album flow (with mobile deep link fallback).- */- onJoinAlbum?: () => void;- /**- * `true` if comments are enabled on the public link.- *- * When `false`, the comment button and comments sidebar will be hidden.+ * `true` if comments and reactions are enabled.* Defaults to `true`.*/enableComment?: boolean;@@ -395,14 +364,6 @@ export type FileViewerProps = ModalVisibilityProps & {* users. Defaults to `true`.*/isCommentsFeatureEnabled?: boolean;- /**- * `true` if the "Join album" option is enabled for this public link.- *- * When `false`, the "Join album and like/comment" button will be hidden- * in the public like/comment modals.- * Defaults to `true`.- */- enableJoin?: boolean;} & Pick<FileInfoProps,"collectionNameByID" | "onSelectCollection" | "onSelectPerson"@@ -443,18 +404,13 @@ export const FileViewer: React.FC<FileViewerProps> = ({onSaveEditedImageCopy,onAddFileToCollection,activeCollectionID,- publicAlbumsCredentials,shouldCloseOnBrowserBack: shouldCloseOnBrowserBackOverride,disableEscapeClose = false,- collectionKey,- onJoinAlbum,enableComment = true,isCommentsFeatureEnabled = true,- enableJoin = true,}) => {const { onGenericError } = useBaseContext();- const shouldCloseOnBrowserBack =- shouldCloseOnBrowserBackOverride ?? !!publicAlbumsCredentials;+ const shouldCloseOnBrowserBack = shouldCloseOnBrowserBackOverride ?? false;// There are 3 things involved in this dance://@@ -501,8 +457,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({const [openComments, setOpenComments] = useState(false);const [openLikes, setOpenLikes] = useState(false);const [openLikeAlbumSelector, setOpenLikeAlbumSelector] = useState(false);- const [openPublicLikeModal, setOpenPublicLikeModal] = useState(false);- const [openAddNameModal, setOpenAddNameModal] = useState(false);const [moreMenuAnchorEl, setMoreMenuAnchorEl] =useState<HTMLElement | null>(null);const [openImageEditor, setOpenImageEditor] = useState(false);@@ -595,6 +549,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({// Helper to get current user's file reactions from allReactionsconst getUserFileReactions = useCallback((fileId: number): { collectionId: number; reactionId: string }[] => {+ if (!user?.id) return [];const fileReactionsMap = allReactionsRef.current.get(fileId);if (!fileReactionsMap) return [];@@ -603,9 +558,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({reactionId: string;}[] = [];for (const [collectionId, reactions] of fileReactionsMap) {- // Get stored anonymous identity for this specific collection- const storedAnonIdentity = getStoredAnonIdentity(collectionId);-const userFileReaction = reactions.find((r) => {if (r.commentID ||@@ -613,15 +565,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({r.reactionType !== "green_heart")return false;- // Check for logged-in user- if (user?.id && r.userID === user.id) return true;- // Check for anonymous user- if (- storedAnonIdentity &&- r.anonUserID === storedAnonIdentity.anonUserID- )- return true;- return false;+ return r.userID === user.id;});if (userFileReaction) {userReactions.push({@@ -653,7 +597,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({setOpenComments(false);setOpenLikes(false);setOpenLikeAlbumSelector(false);- setOpenPublicLikeModal(false);// No need to `resetMoreMenuButtonOnMenuClose` since we're closing// anyway and it'll be removed from the DOM.setMoreMenuAnchorEl(null);@@ -792,119 +735,11 @@ export const FileViewer: React.FC<FileViewerProps> = ({const activeAnnotatedFileRef = useRef(activeAnnotatedFile);activeAnnotatedFileRef.current = activeAnnotatedFile;- const isPublicAlbum = isOfficialAlbumsApp || !!publicAlbumsCredentials;-// Called when the like button (heart) is clicked.- // - If public album: toggle like (unlike if already liked, else show modal)// - If gallery view: show album selector (like) OR unlike selector/direct delete// - If collection view: toggle like in that collectionconst handleLikeClick = useCallback(() => {- if (isPublicAlbum) {- const file = activeAnnotatedFileRef.current?.file;- if (!file || !publicAlbumsCredentials) {- setOpenPublicLikeModal(true);- return;- }-- const fileId = file.id;- const collectionId = file.collectionID;- const storedAnonIdentity = getStoredAnonIdentity(collectionId);-- // Check if already liked by current anon user (file-level only, not comment likes)- const fileReactionsMap = allReactionsRef.current.get(fileId);- const collectionReactions =- fileReactionsMap?.get(collectionId) ?? [];- const existingReaction = collectionReactions.find(- (r) =>- r.reactionType === "green_heart" &&- !r.commentID &&- storedAnonIdentity &&- r.anonUserID === storedAnonIdentity.anonUserID,- );-- if (existingReaction) {- // Already liked - unlike (delete reaction)- void (async () => {- try {- await deletePublicReaction(- publicAlbumsCredentials,- collectionId,- existingReaction.id,- );-- // Update local state- setAllReactions((prev) => {- const next = new Map(prev);- const fileReactionsMap = new Map<- number,- UnifiedReaction[]- >(prev.get(fileId) ?? new Map());- const updatedReactions = (- fileReactionsMap.get(collectionId) ?? []- ).filter((r) => r.id !== existingReaction.id);- fileReactionsMap.set(- collectionId,- updatedReactions,- );- next.set(fileId, fileReactionsMap);- return next;- });- } catch (e) {- log.error("Failed to delete public reaction", e);- }- })();- } else if (storedAnonIdentity) {- // Has identity but not liked - add reaction directly- void (async () => {- try {- if (!collectionKey) {- log.error(- "Missing collection key for public reaction",- );- return;- }- const reactionId = await addPublicReaction(- publicAlbumsCredentials,- collectionId,- fileId,- "green_heart",- collectionKey,- );-- // Update local state- setAllReactions((prev) => {- const next = new Map(prev);- const fileReactionsMap = new Map<- number,- UnifiedReaction[]- >(prev.get(fileId) ?? new Map());- const collectionReactions =- fileReactionsMap.get(collectionId) ?? [];- fileReactionsMap.set(collectionId, [- ...collectionReactions,- {- id: reactionId,- collectionID: collectionId,- fileID: fileId,- reactionType: "green_heart",- userID: 0,- anonUserID: storedAnonIdentity.anonUserID,- isDeleted: false,- createdAt: Date.now() * 1000,- updatedAt: Date.now() * 1000,- },- ]);- next.set(fileId, fileReactionsMap);- return next;- });- } catch (e) {- log.error("Failed to add public reaction", e);- }- })();- } else {- // No identity - show modal to get name- setOpenPublicLikeModal(true);- }+ if (!user?.id) {return;}@@ -1083,14 +918,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({})();}}- }, [- activeCollectionID,- getUserFileReactions,- user?.id,- isPublicAlbum,- publicAlbumsCredentials,- collectionKey,- ]);+ }, [activeCollectionID, getUserFileReactions, user?.id]);const handleLikeAlbumSelectorClose = useCallback(() => setOpenLikeAlbumSelector(false),@@ -1257,119 +1085,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({collectionSummaries,]);- const handlePublicLikeModalClose = useCallback(- () => setOpenPublicLikeModal(false),- [],- );-- const handleLikeAnonymously = useCallback(() => {- setOpenPublicLikeModal(false);- setOpenAddNameModal(true);- }, []);-- const handleJoinAlbumToLike = useCallback(() => {- setOpenPublicLikeModal(false);- onJoinAlbum?.();- }, [onJoinAlbum]);-- const handleAddNameModalClose = useCallback(- () => setOpenAddNameModal(false),- [],- );-- const handleAddNameSubmit = useCallback(- (name: string) => {- const file = activeAnnotatedFileRef.current?.file;- if (!file || !publicAlbumsCredentials || !collectionKey) {- log.error(- "Missing file, credentials, or collection key for public reaction",- );- setOpenAddNameModal(false);- return;- }-- const fileId = file.id;- // Use file.collectionID for public albums since activeCollectionID is a pseudo ID (0)- const collectionId =- activeCollectionID && activeCollectionID > 0- ? activeCollectionID- : file.collectionID;-- void (async () => {- try {- // Check if we already have an anon identity for this collection, otherwise create one- let identity = getStoredAnonIdentity(collectionId);- if (!identity) {- identity = await createAnonIdentity(- publicAlbumsCredentials,- collectionId,- name,- collectionKey,- );- }-- // Add the public reaction- const reactionId = await addPublicReaction(- publicAlbumsCredentials,- collectionId,- fileId,- "green_heart",- collectionKey,- identity,- );-- // Update local state- setAllReactions((prev) => {- const next = new Map(prev);- const fileReactionsMap = new Map<- number,- UnifiedReaction[]- >(prev.get(fileId) ?? new Map());- const collectionReactions =- fileReactionsMap.get(collectionId) ?? [];- fileReactionsMap.set(collectionId, [- ...collectionReactions,- {- id: reactionId,- collectionID: collectionId,- fileID: fileId,- reactionType: "green_heart",- // Use a special userID for anonymous users (derived from anonUserID)- userID: 0,- anonUserID: identity.anonUserID,- isDeleted: false,- createdAt: Date.now() * 1000,- updatedAt: Date.now() * 1000,- },- ]);- next.set(fileId, fileReactionsMap);- return next;- });-- // Update anonUserNames so the name shows immediately in likers list- setAnonUserNames((prev) => {- const next = new Map(prev);- next.set(identity.anonUserID, name);- return next;- });-- setOpenAddNameModal(false);- setOpenLikes(true);- } catch (e) {- log.error("Failed to add public reaction", e);- onGenericError(e);- setOpenAddNameModal(false);- }- })();- },- [- activeCollectionID,- publicAlbumsCredentials,- collectionKey,- onGenericError,- ],- );-// Callback invoked when the download action is triggered by activating the// download button in the PhotoSwipe bar.const handleDownloadBarAction = useCallback(@@ -1520,8 +1235,8 @@ export const FileViewer: React.FC<FileViewerProps> = ({// Logged in users see the download option in the more menu.return "menu";} else {- // In public albums, the download option is shown in the bar- // buttons, in lieu of the favorite option.+ // Guest viewers show download in the bar buttons, in lieu+ // of the favorite option.return "bar";}})();@@ -1585,10 +1300,9 @@ export const FileViewer: React.FC<FileViewerProps> = ({const haveUser = !!user;// Determine if social buttons (like, comment) should be shown.- // They're shown for public albums or when viewing a shared collection.const showSocialButtons = useMemo(() => {- // Show for public albums (no logged-in user).- if (!haveUser) return true;+ if (!haveUser) return false;+ if (!enableComment) return false;// For logged-in users, check if the comments feature is enabled.if (!isCommentsFeatureEnabled) return false;// In collection view: check if that specific collection is shared.@@ -1604,6 +1318,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({return false;}, [haveUser,+ enableComment,isCommentsFeatureEnabled,activeCollectionID,collectionSummaries,@@ -1625,11 +1340,9 @@ export const FileViewer: React.FC<FileViewerProps> = ({// Delegate callback to check if social buttons should be shown for a file.const shouldShowSocialButtons_ = useCallback(({ file }: FileViewerAnnotatedFile): boolean => {- // If showSocialButtons is already true (public album or in shared- // collection view), this won't be called. This callback is only- // for gallery view where we need to check per-file.- //- // For logged-in users, require the comments feature to be enabled.+ // If showSocialButtons is already true in collection view, this+ // won't be called. This callback is only for gallery view where we+ // need to check per-file.if (!isCommentsFeatureEnabled) return false;//// If we're in a specific collection context (not gallery view),@@ -1671,21 +1384,10 @@ export const FileViewer: React.FC<FileViewerProps> = ({if (fileReactionsMap) {for (const [collectionId, reactions] of fileReactionsMap) {- // Get stored anonymous identity for this specific collection- const storedAnonIdentity = getStoredAnonIdentity(collectionId);-const hasUserLike = reactions.some((r) => {if (r.commentID || r.reactionType !== "green_heart")return false;- // Check for logged-in user- if (user?.id && r.userID === user.id) return true;- // Check for anonymous user- if (- storedAnonIdentity &&- r.anonUserID === storedAnonIdentity.anonUserID- )- return true;- return false;+ return r.userID === user?.id;});if (hasUserLike) {likedAlbumIDs.add(collectionId);@@ -1740,22 +1442,11 @@ export const FileViewer: React.FC<FileViewerProps> = ({if (!fileReactionsMap) return false;// Check if user has liked this file in any collection- for (const [collectionId, reactions] of fileReactionsMap) {- // Get stored anonymous identity for this specific collection- const storedAnonIdentity = getStoredAnonIdentity(collectionId);-+ for (const reactions of fileReactionsMap.values()) {const hasUserLike = reactions.some((r) => {if (r.commentID || r.reactionType !== "green_heart")return false;- // Check for logged-in user- if (user?.id && r.userID === user.id) return true;- // Check for anonymous user- if (- storedAnonIdentity &&- r.anonUserID === storedAnonIdentity.anonUserID- )- return true;- return false;+ return r.userID === user?.id;});if (hasUserLike) return true;}@@ -1815,7 +1506,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({openComments ||openLikes ||openLikeAlbumSelector ||- openPublicLikeModal ||!!moreMenuAnchorEl ||openImageEditor ||openConfirmDelete ||@@ -1848,7 +1538,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({openComments,openLikes,openLikeAlbumSelector,- openPublicLikeModal,moreMenuAnchorEl,openImageEditor,openConfirmDelete,@@ -2169,123 +1858,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({isCommentsFeatureEnabled,]);- // Fetch social data (comments + reactions) for public albums (when viewing as anonymous user).- useEffect(() => {- if (- !open ||- !enableComment ||- !activeFileID ||- !publicAlbumsCredentials ||- !collectionKey- )- return;-- const file = files.find((f) => f.id === activeFileID);- if (!file) return;-- void (async () => {- try {- // Fetch both comments and reactions in a single API call- const { comments, reactions } = await getPublicSocialDiff(- publicAlbumsCredentials,- activeFileID,- collectionKey,- );-- // Convert PublicComment to Comment format- const commentsForFile: Comment[] = comments.map((c) => ({- id: c.id,- collectionID: c.collectionID,- fileID: c.fileID,- parentCommentID: c.parentCommentID,- userID: c.userID,- anonUserID: c.anonUserID,- text: c.text,- isDeleted: c.isDeleted,- createdAt: c.createdAt,- updatedAt: c.updatedAt,- }));-- const commentsMap = new Map<number, Comment[]>();- commentsMap.set(file.collectionID, commentsForFile);-- setFileComments((prev) => {- const next = new Map(prev);- next.set(activeFileID, commentsMap);- return next;- });-- // Convert PublicReaction to UnifiedReaction format- const unifiedReactions: UnifiedReaction[] = reactions.map(- (r) => ({- id: r.id,- collectionID: file.collectionID,- fileID: r.fileID,- commentID: r.commentID,- reactionType: r.reactionType,- userID: r.userID,- anonUserID: r.anonUserID,- isDeleted: r.isDeleted,- createdAt: r.createdAt,- updatedAt: r.updatedAt,- }),- );-- const reactionsMap = new Map<number, UnifiedReaction[]>();- reactionsMap.set(file.collectionID, unifiedReactions);-- setAllReactions((prev) => {- const next = new Map(prev);- next.set(activeFileID, reactionsMap);- return next;- });-- // Fetch anonymous user profiles for public albums- try {- const anonProfiles = await getPublicAnonProfiles(- publicAlbumsCredentials,- collectionKey,- );- setAnonUserNames((prev) => {- const next = new Map(prev);- for (const [id, name] of anonProfiles) {- next.set(id, name);- }- return next;- });- } catch {- // Ignore anon profiles fetch failures- }-- // Fetch registered participants' masked emails for public albums- try {- const participantEmails =- await getPublicParticipantsMaskedEmails(- publicAlbumsCredentials,- );- setUserIDToEmail((prev) => {- const next = new Map(prev);- for (const [id, email] of participantEmails) {- next.set(id, email);- }- return next;- });- } catch {- // Ignore participants fetch failures- }- } catch (e) {- log.error("Failed to fetch public social data", e);- }- })();- }, [- open,- enableComment,- activeFileID,- publicAlbumsCredentials,- collectionKey,- files,- ]);-// Refresh comment count when fileComments changes.useEffect(() => {if (open && files.length) {@@ -2381,113 +1953,10 @@ export const FileViewer: React.FC<FileViewerProps> = ({isCommentsFeatureEnabled,]);- // Refresh social data for public albums- const refreshPublicSocialData = useCallback(async () => {- if (- !activeFileID ||- !publicAlbumsCredentials ||- !collectionKey ||- !enableComment- )- return;-- const file = files.find((f) => f.id === activeFileID);- if (!file) return;-- try {- const { comments, reactions } = await getPublicSocialDiff(- publicAlbumsCredentials,- activeFileID,- collectionKey,- );-- const commentsForFile: Comment[] = comments.map((c) => ({- id: c.id,- collectionID: c.collectionID,- fileID: c.fileID,- parentCommentID: c.parentCommentID,- userID: c.userID,- anonUserID: c.anonUserID,- text: c.text,- isDeleted: c.isDeleted,- createdAt: c.createdAt,- updatedAt: c.updatedAt,- }));-- const commentsMap = new Map<number, Comment[]>();- commentsMap.set(file.collectionID, commentsForFile);-- setFileComments((prev) => {- const next = new Map(prev);- next.set(activeFileID, commentsMap);- return next;- });-- const unifiedReactions: UnifiedReaction[] = reactions.map((r) => ({- id: r.id,- collectionID: file.collectionID,- fileID: r.fileID,- commentID: r.commentID,- reactionType: r.reactionType,- userID: r.userID,- anonUserID: r.anonUserID,- isDeleted: r.isDeleted,- createdAt: r.createdAt,- updatedAt: r.updatedAt,- }));-- const reactionsMap = new Map<number, UnifiedReaction[]>();- reactionsMap.set(file.collectionID, unifiedReactions);-- setAllReactions((prev) => {- const next = new Map(prev);- next.set(activeFileID, reactionsMap);- return next;- });-- // Fetch anon profiles (new anonymous users may have commented)- try {- const anonProfiles = await getPublicAnonProfiles(- publicAlbumsCredentials,- collectionKey,- );- setAnonUserNames((prev) => {- const next = new Map(prev);- for (const [id, name] of anonProfiles) {- next.set(id, name);- }- return next;- });- } catch {- // Ignore- }- // Note: Masked emails for registered participants are fetched only- // on initial load since they rarely change during a session.- } catch (e) {- log.error("Failed to refresh public social data", e);- }- }, [- activeFileID,- publicAlbumsCredentials,- collectionKey,- enableComment,- files,- ]);-- // Poll for social data when comments or likes sidebar is open (logged-in users)+ // Poll for social data when comments or likes sidebar is open.useInterval(refreshSocialData,- (openComments || openLikes) && !publicAlbumsCredentials- ? SOCIAL_REFRESH_INTERVAL_MS- : null,- );-- // Poll for social data when comments or likes sidebar is open (public albums)- useInterval(- refreshPublicSocialData,- (openComments || openLikes) && publicAlbumsCredentials- ? SOCIAL_REFRESH_INTERVAL_MS- : null,+ openComments || openLikes ? SOCIAL_REFRESH_INTERVAL_MS : null,);useEffect(() => {@@ -2498,7 +1967,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({const pswp = new FileViewerPhotoSwipe({initialIndex,haveUser,- isPublicAlbum,showSocialButtons,enableComment,showFullscreenButton,@@ -2546,7 +2014,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({showFullscreenButton,disableEscapeClose,haveUser,- isPublicAlbum,handleClose,handleAnnotate,handleViewInfo,@@ -2560,8 +2027,8 @@ export const FileViewer: React.FC<FileViewerProps> = ({useEffect(() => {if (!open || !shouldCloseOnBrowserBack) return;- // In public albums, consume one browser-back action to close the- // viewer overlay instead of navigating away from the shared link.+ // Consume one browser-back action to close the viewer overlay instead+ // of navigating away immediately.const stateMarker = `${Date.now()}-${Math.random().toString(36).slice(2)}`;browserBackStateRef.current = stateMarker;@@ -2654,11 +2121,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({onCommentReactionAdded={handleCommentReactionAdded}onCommentReactionDeleted={handleCommentReactionDeleted}highlightCommentID={highlightCommentID}- publicAlbumsCredentials={publicAlbumsCredentials}- collectionKey={collectionKey}anonUserNames={anonUserNames}- onJoinAlbum={onJoinAlbum}- enableJoin={enableJoin}/><LikesSidebaropen={openLikes}@@ -2682,18 +2145,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({onToggleAlbum={handleToggleAlbumLike}onLikeAll={handleLikeAll}/>- <PublicLikeModal- open={openPublicLikeModal}- onClose={handlePublicLikeModalClose}- onLikeAnonymously={handleLikeAnonymously}- onJoinAlbumToLike={handleJoinAlbumToLike}- enableJoin={enableJoin}- />- <AddNameModal- open={openAddNameModal}- onClose={handleAddNameModalClose}- onSubmit={handleAddNameSubmit}- /><MoreMenuopen={!!moreMenuAnchorEl}onClose={handleMoreMenuCloseIfNeeded}diff --git a/web/packages/gallery/components/viewer/LikesSidebar.tsx b/web/packages/gallery/components/viewer/LikesSidebar.tsxindex 05fb404a65..91b2bf9e47 100644--- a/web/packages/gallery/components/viewer/LikesSidebar.tsx+++ b/web/packages/gallery/components/viewer/LikesSidebar.tsx@@ -14,7 +14,6 @@ import log from "ente-base/log";import { downloadManager } from "ente-gallery/services/download";import { getAvatarColor } from "ente-gallery/utils/avatar-colors";import type { EnteFile } from "ente-media/file";-import { getStoredAnonIdentity } from "ente-new/albums/services/public-reaction";import type { CollectionSummaries } from "ente-new/photos/services/collection-summary";import { type UnifiedReaction } from "ente-new/photos/services/social";import { t } from "i18next";@@ -187,7 +186,7 @@ export const LikesSidebar: React.FC<LikesSidebarProps> = ({if (!file) return [];const allCollectionIDs = fileNormalCollectionIDs?.get(file.id) ?? [];- // If no collection IDs from fileNormalCollectionIDs (e.g., public album),+ // If no collection IDs from fileNormalCollectionIDs,// use the file's collection ID directlyif (allCollectionIDs.length === 0) {return [file.collectionID];@@ -244,11 +243,6 @@ export const LikesSidebar: React.FC<LikesSidebarProps> = ({const reactions =reactionsByCollection.get(selectedCollectionInfo.id) ?? [];- // Get stored anonymous identity for this collection to check if current anon user- const storedAnonIdentity = getStoredAnonIdentity(- selectedCollectionInfo.id,- );-return reactions.filter((r) => r.reactionType === "green_heart").sort((a, b) => b.createdAt - a.createdAt) // Most recent first@@ -257,11 +251,8 @@ export const LikesSidebar: React.FC<LikesSidebarProps> = ({const isAnonymous =r.anonUserID || r.userID === 0 || r.userID === -1;- // Check if this is the current user (logged-in or anonymous)+ // Check if this is the current logged-in user.const isCurrentUser = r.userID === currentUserID;- const isCurrentAnonUser =- storedAnonIdentity &&- r.anonUserID === storedAnonIdentity.anonUserID;let email: string;let userName: string;@@ -277,13 +268,11 @@ export const LikesSidebar: React.FC<LikesSidebarProps> = ({`${t("anonymous")} ${r.anonUserID?.slice(-4) ?? ""}`;// Use actualName for avatar color (varying length like mobile emails)email = actualName;- userName = isCurrentAnonUser ? t("you") : actualName;+ userName = actualName;} else {const emailFromMap = prefetchedUserIDToEmail?.get(r.userID);// Use userID as string for unique avatar coloremail = emailFromMap ?? String(r.userID);- // In public albums (no currentUserID), non-anonymous- // users are album owner or collaboratorsactualName = emailFromMap ?? t("anonymous");userName = isCurrentUser ? t("you") : actualName;}diff --git a/web/packages/gallery/components/viewer/PublicCommentModal.tsx b/web/packages/gallery/components/viewer/PublicCommentModal.tsxdeleted file mode 100644index b3590af12b..0000000000--- a/web/packages/gallery/components/viewer/PublicCommentModal.tsx+++ /dev/null@@ -1,304 +0,0 @@-import CloseIcon from "@mui/icons-material/Close";-import {- Box,- Button,- Dialog,- IconButton,- styled,- Typography,-} from "@mui/material";-import { type ModalVisibilityProps } from "ente-base/components/utils/modal";-import { t } from "i18next";-import React from "react";--// =============================================================================-// Icons-// =============================================================================--const CommentIllustration: React.FC = () => (- <svg- width="146"- height="104"- viewBox="0 0 146 104"- fill="none"- xmlns="http://www.w3.org/2000/svg"- >- <path- d="M62.4161 23.9825C69.5416 21.6377 77.2027 21.4587 84.4301 23.4677C91.6577 25.4768 98.1278 29.5846 103.021 35.2705C107.914 40.9564 111.011 47.9656 111.921 55.4117C112.83 62.8579 111.511 70.4066 108.131 77.1033C104.75 83.8 99.4603 89.3444 92.929 93.0344C86.3977 96.7244 78.9186 98.3952 71.438 97.8347C65.5124 97.3907 59.9955 95.6061 55.1766 92.7912L36.6137 95.1736C35.7803 95.2805 34.9485 94.962 34.4004 94.3252C33.8523 93.6882 33.6604 92.8183 33.8903 92.0101L39.0115 74.0065C36.9468 68.823 36.0051 63.1057 36.4493 57.1772C37.0098 49.6966 39.7764 42.5499 44.3984 36.6414C49.0204 30.733 55.2905 26.3274 62.4161 23.9825Z"- fill="#08C225"- stroke="#232323"- strokeWidth="5"- strokeLinecap="round"- strokeLinejoin="round"- />- <mask- id="mask0_737_21326"- style={{ maskType: "alpha" }}- maskUnits="userSpaceOnUse"- x="36"- y="24"- width="74"- height="72"- >- <path- d="M71.6249 95.341C78.6125 95.8645 85.5985 94.3043 91.6993 90.8575C97.8002 87.4107 102.742 82.2321 105.899 75.9768C109.057 69.7214 110.289 62.6702 109.439 55.7147C108.59 48.7592 105.696 42.2119 101.126 36.9007C96.5551 31.5895 90.512 27.753 83.7608 25.8763C77.0096 23.9996 69.8535 24.167 63.1974 26.3573C56.5414 28.5477 50.6843 32.6626 46.3669 38.1817C42.0494 43.7008 39.4656 50.3762 38.942 57.3639C38.5044 63.2051 39.5049 68.8185 41.6537 73.8587L36.2949 92.6938L55.7183 90.2015C60.382 93.0774 65.7876 94.9037 71.6249 95.341Z"- fill="#08C225"- />- </mask>- <g mask="url(#mask0_737_21326)">- <path- d="M90.785 29.2779C55.9844 19.5648 41.0889 44.5028 37.9912 58.186L34.2834 72.1186C32.1784 72.553 27.1513 72.4724 23.883 68.6747C19.7976 63.9275 7.9607 55.936 8.75491 45.336C9.54911 34.736 9.85699 18.7723 10.8726 17.072C11.6851 15.7117 48.8217 4.51972 67.2885 -0.90625L123.817 3.32912C127.307 16.0258 125.586 38.991 90.785 29.2779Z"- fill="white"- />- <path- d="M68.1126 36.8926C67.7871 34.8769 69.5702 32.9123 72.0953 32.5044C74.6204 32.0966 76.9313 33.4 77.2568 35.4157C77.5824 37.4313 75.7993 39.3959 73.2742 39.8038C70.7491 40.2116 68.4382 38.9082 68.1126 36.8926Z"- fill="white"- />- <path- d="M63.6068 40.3106C63.4959 39.624 64.1063 38.9542 64.9702 38.8147C65.834 38.6752 66.6242 39.1187 66.7351 39.8054C66.846 40.492 66.2356 41.1618 65.3718 41.3013C64.5079 41.4408 63.7177 40.9973 63.6068 40.3106Z"- fill="white"- />- <path- d="M35.0516 84.4974C50.0736 86.3458 84.2825 85.3953 100.941 66.8061C117.601 48.217 131.472 23.1618 129.517 33.958C128.008 42.824 108.57 103.778 97.3574 108.665C83.3409 114.774 55.5151 127.853 46.4893 128.205C37.4635 128.557 25.3268 115.992 24.0509 114.477C22.775 112.962 24.2879 103.196 26.2494 99.9921C27.959 97.1997 26.5317 91.4899 26.2742 90.6394C26.2622 90.6323 26.2542 90.6209 26.2503 90.6048C26.2237 90.4942 26.2362 90.514 26.2742 90.6394C26.7756 90.9343 34.2208 83.5106 35.0516 84.4974Z"- fill="#24B41F"- />- <path- d="M63.1172 64.2407C65.5626 64.2849 67.581 62.3384 67.6253 59.8929C67.6695 57.4475 65.723 55.4291 63.2775 55.3849C60.8321 55.3406 58.8137 57.2871 58.7694 59.7326C58.7252 62.1781 60.6717 64.1964 63.1172 64.2407Z"- fill="#232323"- />- <path- d="M75.293 64.4555C77.7384 64.4998 79.7568 62.5532 79.801 60.1078C79.8453 57.6623 77.8988 55.644 75.4533 55.5997C73.0078 55.5554 70.9895 57.502 70.9452 59.9474C70.901 62.3929 72.8475 64.4112 75.293 64.4555Z"- fill="#232323"- />- <path- d="M87.4707 64.6821C89.9162 64.7263 91.9345 62.7798 91.9788 60.3343C92.023 57.8889 90.0765 55.8705 87.631 55.8263C85.1856 55.782 83.1672 57.7285 83.123 60.174C83.0787 62.6195 85.0252 64.6378 87.4707 64.6821Z"- fill="#232323"- />- </g>- <path- d="M20.1099 75.4512C14.3314 77.6905 10.4661 82.396 10.8043 87.5689C10.4661 82.396 6.02735 78.2395 0 76.7661C5.77852 74.5268 9.64385 69.8213 9.30562 64.6484C9.64385 69.8213 14.0826 73.9778 20.1099 75.4512Z"- fill="#08C225"- />- <path- d="M145.699 62.5334C138.037 63.2295 131.824 67.5164 130.457 73.8026C131.824 67.5164 127.951 61.0368 121.27 57.2223C128.932 56.5261 135.145 52.2393 136.512 45.9531C135.145 52.2393 139.017 58.7188 145.699 62.5334Z"- fill="#08C225"- />- <path- d="M51.1361 8.83653C46.9208 9.50979 43.6377 12.1205 43.1181 15.6532C43.6377 12.1205 41.2488 8.67983 37.4023 6.81669C41.6176 6.14343 44.9007 3.53273 45.4202 0C44.9007 3.53273 47.2896 6.97339 51.1361 8.83653Z"- fill="#08C225"- />- </svg>-);--// =============================================================================-// Types-// =============================================================================--export interface PublicCommentModalProps extends ModalVisibilityProps {- /**- * Called when user clicks "Comment anonymously".- */- onCommentAnonymously: () => void;- /**- * Called when user clicks "Join album and comment".- */- onJoinAlbumToComment: () => void;- /**- * Whether the "Join album" option is enabled for this public link.- * When false, the "Join album and comment" button will be hidden.- */- enableJoin?: boolean;-}--/**- * Modal dialog for commenting on a photo in a public album.- * Shows options to comment anonymously or sign in to comment.- */-export const PublicCommentModal: React.FC<PublicCommentModalProps> = ({- open,- onClose,- onCommentAnonymously,- onJoinAlbumToComment,- enableJoin = true,-}) => {- return (- <StyledDialog open={open} onClose={onClose}>- <DialogWrapper>- <CloseButton onClick={onClose}>- <CloseIcon sx={{ fontSize: 20 }} />- </CloseButton>-- <ContentContainer>- <IllustrationWrapper>- <CommentIllustration />- </IllustrationWrapper>-- <TitleSection>- <Title>{t("say_something_nice")}</Title>- {enableJoin && (- <Subtitle>{t("public_comment_subtitle")}</Subtitle>- )}- </TitleSection>-- <ButtonsSection sx={!enableJoin ? { mt: 4 } : undefined}>- {enableJoin ? (- <AnonymousButton- variant="outlined"- fullWidth- onClick={onCommentAnonymously}- >- {t("comment_anonymously")}- </AnonymousButton>- ) : (- <SignInButton- variant="contained"- fullWidth- onClick={onCommentAnonymously}- >- {t("comment_anonymously")}- </SignInButton>- )}- {enableJoin && (- <SignInButton- variant="contained"- fullWidth- onClick={onJoinAlbumToComment}- >- {t("join_album_and_comment")}- </SignInButton>- )}- </ButtonsSection>- </ContentContainer>- </DialogWrapper>- </StyledDialog>- );-};--// =============================================================================-// Styled Components-// =============================================================================--const StyledDialog = styled(Dialog)(({ theme }) => ({- "& .MuiDialog-paper": {- width: 381,- maxWidth: "calc(100% - 32px)",- borderRadius: 28,- backgroundColor: "#fff",- padding: 0,- margin: 16,- overflow: "visible",- boxShadow: "none",- border: "1px solid #E0E0E0",- ...theme.applyStyles("dark", {- backgroundColor: "#1b1b1b",- border: "1px solid rgba(255, 255, 255, 0.18)",- }),- },- "& .MuiBackdrop-root": { backgroundColor: "rgba(0, 0, 0, 0.5)" },-}));--const DialogWrapper = styled(Box)(() => ({- position: "relative",- padding: "48px 16px 16px 16px",-}));--const CloseButton = styled(IconButton)(({ theme }) => ({- position: "absolute",- top: 11,- right: 12,- backgroundColor: "#FAFAFA",- color: "#000",- padding: 10,- "&:hover": { backgroundColor: "#F0F0F0" },- ...theme.applyStyles("dark", {- backgroundColor: "rgba(255, 255, 255, 0.12)",- color: "#fff",- "&:hover": { backgroundColor: "rgba(255, 255, 255, 0.16)" },- }),-}));--const ContentContainer = styled(Box)(() => ({- display: "flex",- flexDirection: "column",- alignItems: "center",- gap: 16,-}));--const IllustrationWrapper = styled(Box)(() => ({- display: "flex",- justifyContent: "center",- alignItems: "center",- marginBottom: 8,-}));--const TitleSection = styled(Box)(() => ({- display: "flex",- flexDirection: "column",- alignItems: "center",- gap: 9,- textAlign: "center",- marginBottom: 16,-}));--const Title = styled(Typography)(({ theme }) => ({- fontWeight: 600,- fontSize: 24,- lineHeight: "28px",- letterSpacing: "-0.48px",- color: "#000",- ...theme.applyStyles("dark", { color: "#fff" }),-}));--const Subtitle = styled(Typography)(({ theme }) => ({- fontWeight: 500,- fontSize: 14,- lineHeight: "20px",- color: "#666666",- maxWidth: 240,- ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.7)" }),-}));--const ButtonsSection = styled(Box)(() => ({- width: "100%",- display: "flex",- flexDirection: "column",- gap: 12,-}));--const AnonymousButton = styled(Button)(({ theme }) => ({- display: "flex",- padding: "20px 16px",- justifyContent: "center",- alignItems: "center",- gap: 8,- flex: "1 0 0",- borderRadius: 20,- backgroundColor: "rgba(0, 0, 0, 0.04)",- border: "none",- fontSize: 16,- fontWeight: 500,- textTransform: "none",- color: "#000",- "&:hover": { backgroundColor: "rgba(0, 0, 0, 0.08)", border: "none" },- ...theme.applyStyles("dark", {- backgroundColor: "rgba(255, 255, 255, 0.08)",- color: "#fff",- "&:hover": { backgroundColor: "rgba(255, 255, 255, 0.12)" },- }),-}));--const SignInButton = styled(Button)(() => ({- display: "flex",- padding: "20px 16px",- justifyContent: "center",- alignItems: "center",- gap: 8,- flex: "1 0 0",- borderRadius: 20,- backgroundColor: "#08C225",- fontSize: 16,- fontWeight: 500,- textTransform: "none",- color: "#fff",- "&:hover": { backgroundColor: "#07A820" },-}));diff --git a/web/packages/gallery/components/viewer/PublicFeedSidebar.tsx b/web/packages/gallery/components/viewer/PublicFeedSidebar.tsxdeleted file mode 100644index 08eea1b292..0000000000--- a/web/packages/gallery/components/viewer/PublicFeedSidebar.tsx+++ /dev/null@@ -1,1029 +0,0 @@-import CloseIcon from "@mui/icons-material/Close";-import {- Avatar,- Box,- CircularProgress,- Drawer,- IconButton,- Stack,- styled,- Typography,-} from "@mui/material";-import { useColorScheme } from "@mui/material/styles";-import { useInterval } from "ente-base/components/utils/hooks";-import { type ModalVisibilityProps } from "ente-base/components/utils/modal";-import type { PublicAlbumsCredentials } from "ente-base/http";-import log from "ente-base/log";-import { downloadManager } from "ente-gallery/services/download";-import { getAvatarColor } from "ente-gallery/utils/avatar-colors";-import type { EnteFile } from "ente-media/file";-import { FileType } from "ente-media/file-type";-import {- getPublicAlbumFeed,- getPublicAnonProfiles,- getPublicParticipantsMaskedEmails,- type PublicFeedComment,- type PublicFeedReaction,-} from "ente-new/albums/services/public-reaction";-import { t } from "i18next";-import React, { useCallback, useEffect, useMemo, useState } from "react";--// =============================================================================-// Icons-// =============================================================================--const LikedPhotoIcon: React.FC = () => (- <svg- width="17"- height="15"- viewBox="0 0 17 15"- fill="none"- xmlns="http://www.w3.org/2000/svg"- >- <path- d="M6.99906 13.1537C4.84391 11.5421 0.574219 7.85775 0.574219 4.54219C0.574219 2.35074 2.1824 0.574219 4.39366 0.574219C5.5395 0.574219 6.68533 0.956163 8.21311 2.48394C9.74089 0.956163 10.8867 0.574219 12.0326 0.574219C14.2438 0.574219 15.852 2.35074 15.852 4.54219C15.852 7.85775 11.5823 11.5421 9.42716 13.1537C8.70192 13.696 7.7243 13.696 6.99906 13.1537Z"- fill="#08C225"- stroke="#08C225"- strokeWidth="1.14583"- strokeLinecap="round"- strokeLinejoin="round"- />- </svg>-);--const CommentedPhotoIcon: React.FC = () => (- <svg- width="15"- height="15"- viewBox="0 0 15 15"- fill="none"- xmlns="http://www.w3.org/2000/svg"- >- <path- d="M7.5 14.25C8.83502 14.25 10.1401 13.8541 11.2501 13.1124C12.3601 12.3707 13.2253 11.3165 13.7362 10.0831C14.2471 8.84971 14.3808 7.49252 14.1203 6.18314C13.8598 4.87377 13.217 3.67104 12.273 2.72703C11.329 1.78303 10.1262 1.14015 8.81686 0.879702C7.50749 0.619252 6.15029 0.752925 4.91689 1.26382C3.68349 1.77471 2.62928 2.63987 1.88758 3.7499C1.14588 4.85994 0.75 6.16498 0.75 7.5C0.75 8.616 1.02 9.66825 1.5 10.5953L0.75 14.25L4.40475 13.5C5.33175 13.98 6.38475 14.25 7.5 14.25Z"- stroke="currentColor"- strokeWidth="1.5"- strokeLinecap="round"- strokeLinejoin="round"- />- </svg>-);--const RepliedCommentIcon: React.FC = () => (- <svg- width="12"- height="9"- viewBox="0 0 12 9"- fill="none"- xmlns="http://www.w3.org/2000/svg"- >- <path- d="M4.2334 0.0849609C4.39661 0.0849817 4.55308 0.151147 4.66797 0.268555C4.78252 0.386006 4.84664 0.544829 4.84668 0.709961C4.84668 0.875074 4.78246 1.03389 4.66797 1.15137L2.1748 3.70215H7.76855C8.41316 3.70215 9.34837 3.88326 10.1738 4.42969L10.3379 4.54297L10.5029 4.67188C11.3155 5.34145 11.918 6.39843 11.918 7.94531C11.9179 8.11049 11.8539 8.26927 11.7393 8.38672C11.6244 8.50422 11.4679 8.57119 11.3047 8.57129C11.1413 8.57129 10.985 8.5043 10.8701 8.38672C10.7553 8.26923 10.6905 8.11066 10.6904 7.94531C10.6904 6.70123 10.1974 5.98489 9.61914 5.55859C9.00926 5.10915 8.25891 4.95312 7.76855 4.95312H2.17578L4.66504 7.50098C4.72518 7.55831 4.77424 7.62756 4.80762 7.7041C4.84094 7.78063 4.85886 7.86362 4.86035 7.94727C4.8618 8.03105 4.84614 8.11459 4.81543 8.19238C4.78472 8.27017 4.73883 8.34087 4.68066 8.40039C4.62251 8.45986 4.55306 8.50745 4.47656 8.53906C4.40013 8.57058 4.31786 8.58645 4.23535 8.58496C4.1528 8.58343 4.07139 8.5646 3.99609 8.53027C3.9207 8.4959 3.85295 8.44634 3.79688 8.38477V8.38379L0.263672 4.76953C0.148973 4.65203 0.0849609 4.49242 0.0849609 4.32715C0.085085 4.16205 0.149084 4.00313 0.263672 3.88574L3.79883 0.268555C3.91373 0.151128 4.07015 0.0849609 4.2334 0.0849609Z"- fill="currentColor"- stroke="currentColor"- strokeWidth="0.166667"- />- </svg>-);--const LikedCommentIcon: React.FC<{ heartStroke?: string }> = ({- heartStroke = "white",-}) => (- <svg- width="22"- height="21"- viewBox="0 0 22 21"- fill="none"- xmlns="http://www.w3.org/2000/svg"- >- <path- d="M9.16797 16.043C10.5277 16.043 11.8569 15.6398 12.9875 14.8843C14.1181 14.1289 14.9993 13.0552 15.5196 11.7989C16.04 10.5427 16.1761 9.16035 15.9109 7.82673C15.6456 6.49311 14.9908 5.2681 14.0293 4.30661C13.0678 3.34513 11.8428 2.69035 10.5092 2.42507C9.17559 2.1598 7.79326 2.29595 6.53702 2.8163C5.28078 3.33665 4.20705 4.21784 3.45162 5.34843C2.69618 6.47901 2.29297 7.80823 2.29297 9.16797C2.29297 10.3046 2.56797 11.3764 3.05686 12.3205L2.29297 16.043L6.0154 15.2791C6.95957 15.768 8.03207 16.043 9.16797 16.043Z"- stroke="currentColor"- strokeWidth="1.52778"- strokeLinecap="round"- strokeLinejoin="round"- />- <path- d="M17.3555 10.0986C18.9264 10.0987 20.0537 11.3666 20.0537 12.8887C20.0536 14.0427 19.3203 15.2043 18.4863 16.1631C17.6399 17.1362 16.6287 17.9692 15.9541 18.4736C15.3852 18.899 14.6148 18.899 14.0459 18.4736C13.3713 17.9692 12.3601 17.1362 11.5137 16.1631C10.6797 15.2043 9.94638 14.0427 9.94629 12.8887C9.94629 11.3666 11.0736 10.0986 12.6445 10.0986C13.3933 10.0986 14.1193 10.34 15 11.1455C15.8807 10.34 16.6067 10.0986 17.3555 10.0986Z"- stroke={heartStroke}- strokeWidth="0.685221"- strokeLinecap="round"- strokeLinejoin="round"- />- <path- d="M14.2513 18.1992C12.9222 17.2053 10.2891 14.9332 10.2891 12.8885C10.2891 11.537 11.2808 10.4414 12.6445 10.4414C13.3511 10.4414 14.0578 10.677 15 11.6191C15.9421 10.677 16.6488 10.4414 17.3554 10.4414C18.7191 10.4414 19.7109 11.537 19.7109 12.8885C19.7109 14.9332 17.0777 17.2053 15.7487 18.1992C15.3014 18.5336 14.6985 18.5336 14.2513 18.1992Z"- fill="#08C225"- stroke="#08C225"- strokeWidth="0.685221"- strokeLinecap="round"- strokeLinejoin="round"- />- </svg>-);--const PersonIcon: React.FC = () => (- <svg- width="16"- height="16"- viewBox="0 0 24 24"- fill="none"- xmlns="http://www.w3.org/2000/svg"- >- <path- d="M12 12C14.21 12 16 10.21 16 8C16 5.79 14.21 4 12 4C9.79 4 8 5.79 8 8C8 10.21 9.79 12 12 12ZM12 14C9.33 14 4 15.34 4 18V20H20V18C20 15.34 14.67 14 12 14Z"- fill="currentColor"- />- </svg>-);--// =============================================================================-// Types-// =============================================================================--/**- * Information about a feed item click for navigation purposes.- */-export interface PublicFeedItemClickInfo {- /** The type of feed item. */- type: PublicFeedItem["type"];- /** The file ID to navigate to. */- fileID: number;- /**- * The comment ID to highlight (for comment-related items).- * For `replied_comment`, this is the reply's comment ID.- * For `liked_comment`, this is the target comment ID.- */- commentID?: string;-}--export interface PublicFeedSidebarProps extends ModalVisibilityProps {- /**- * The files in the album, used to display thumbnails and determine file type.- */- files?: EnteFile[];- /**- * Public album credentials for API access.- */- credentials: PublicAlbumsCredentials;- /**- * The decrypted collection key (base64 encoded).- */- collectionKey: string;- /**- * Called when a feed item is clicked for navigation.- */- onItemClick?: (info: PublicFeedItemClickInfo) => void;-}--/** A user who performed an action in the feed. */-interface FeedUser {- userID: number;- anonUserID?: string;- userName: string;- /** Email/identifier used for avatar color. */- email: string;- /** True if this is a registered user with masked email (show person icon). */- isMaskedEmail: boolean;-}--/** Base interface for all feed items. */-interface BaseFeedItem {- /** Unique identifier for this feed item (for React keys). */- id: string;- /** Timestamp of the most recent action in this item. */- timestamp: number;-}--/** Someone liked a photo/video (grouped by file). */-interface LikedFileFeedItem extends BaseFeedItem {- type: "liked_photo" | "liked_video";- fileID: number;- thumbnailURL?: string;- users: FeedUser[];-}--/** Someone commented on a photo/video. */-interface CommentedFileFeedItem extends BaseFeedItem {- type: "commented_photo" | "commented_video";- fileID: number;- /** The ID of the comment for navigation. */- commentID: string;- thumbnailURL?: string;- user: FeedUser;-}--/** Someone replied to a comment. */-interface RepliedCommentFeedItem extends BaseFeedItem {- type: "replied_comment";- /** The parent comment ID. */- parentCommentID: string;- /** The ID of the reply for navigation. */- replyID: string;- fileID?: number;- thumbnailURL?: string;- user: FeedUser;-}--/** Someone liked a comment (grouped by comment, includes reply likes). */-interface LikedCommentFeedItem extends BaseFeedItem {- type: "liked_comment";- commentID: string;- fileID?: number;- thumbnailURL?: string;- users: FeedUser[];-}--type PublicFeedItem =- | LikedFileFeedItem- | CommentedFileFeedItem- | RepliedCommentFeedItem- | LikedCommentFeedItem;--/** Thumbnail URL cache for files. */-type ThumbnailCache = Map<number, string>;--/** File type cache for determining photo vs video. */-type FileTypeCache = Map<number, number>;--// =============================================================================-// Utility Functions-// =============================================================================--/**- * Get the display name for a user.- * For anonymous users, uses their entered name from userName.- * Falls back to "Anonymous" only if userName is empty.- */-const getUserDisplayName = (- userID: number,- userName: string,- anonUserID?: string,-): string => {- if (userID === -1 || userID === 0 || anonUserID) {- return userName || t("anonymous");- }- return userName;-};--/**- * Process feed items from public album data.- *- * For public albums, we show ALL actions from everyone:- * - X liked a photo/video- * - A liked a comment (includes reply likes)- * - M commented on a photo/video- * - C replied to a comment- */-const processFeedItems = (- comments: PublicFeedComment[],- reactions: PublicFeedReaction[],- thumbnailCache: ThumbnailCache,- fileTypeCache: FileTypeCache,- maskedEmails: Map<number, string>,- anonUserNames: Map<string, string>,-): PublicFeedItem[] => {- const feedItems: PublicFeedItem[] = [];-- // Build a map from commentID to fileID for looking up comment likes- const commentFileIDMap = new Map<string, number>();- for (const c of comments) {- if (c.fileID) {- commentFileIDMap.set(c.id, c.fileID);- }- }-- // Helper to get display name for a user- const getUserName = (userID: number, anonUserID?: string): string => {- if (anonUserID) {- return (- anonUserNames.get(anonUserID) ??- `${t("anonymous")} ${anonUserID.slice(-4)}`- );- }- return maskedEmails.get(userID) ?? t("unknown_user");- };-- // Helper to get avatar color key- const getAvatarColorKey = (userID: number, anonUserID?: string): string => {- if (anonUserID) {- return anonUserNames.get(anonUserID) ?? anonUserID;- }- return maskedEmails.get(userID) ?? String(userID);- };-- // On public albums, all registered users have masked emails- const isRegisteredUser = (anonUserID?: string): boolean => !anonUserID;-- // Helper to get thumbnail URL from cache- const getThumbnailURL = (fileID: number | undefined): string | undefined =>- fileID ? thumbnailCache.get(fileID) : undefined;-- // Helper to determine if file is video- const isVideo = (fileID: number | undefined): boolean => {- if (!fileID) return false;- const fileType = fileTypeCache.get(fileID);- return fileType === FileType.video;- };-- // 1. Process comments - categorize as "commented_photo/video" or "replied_comment"- for (const c of comments) {- if (c.isDeleted) continue;-- const displayName = getUserName(c.userID, c.anonUserID);- const avatarColorKey = getAvatarColorKey(c.userID, c.anonUserID);- const isMaskedEmail = isRegisteredUser(c.anonUserID);-- if (c.isReply && c.parentCommentID) {- // This is a reply to a comment- feedItems.push({- id: `replied_comment_${c.id}`,- type: "replied_comment",- parentCommentID: c.parentCommentID,- replyID: c.id,- fileID: c.fileID,- thumbnailURL: getThumbnailURL(c.fileID),- timestamp: c.createdAt,- user: {- userID: c.userID,- anonUserID: c.anonUserID,- userName: displayName,- email: avatarColorKey,- isMaskedEmail,- },- });- } else if (c.fileID) {- // This is a comment on a photo/video- const fileIsVideo = isVideo(c.fileID);- feedItems.push({- id: `commented_file_${c.id}`,- type: fileIsVideo ? "commented_video" : "commented_photo",- fileID: c.fileID,- commentID: c.id,- thumbnailURL: getThumbnailURL(c.fileID),- timestamp: c.createdAt,- user: {- userID: c.userID,- anonUserID: c.anonUserID,- userName: displayName,- email: avatarColorKey,- isMaskedEmail,- },- });- }- }-- // 2. Process reactions - group by file or comment- // Group file likes by fileID- const fileLikes = new Map<- number,- { users: FeedUser[]; latestTimestamp: number; isVideo: boolean }- >();- // Group comment likes by commentID (includes reply likes)- const commentLikes = new Map<- string,- { users: FeedUser[]; latestTimestamp: number; fileID?: number }- >();-- for (const r of reactions) {- if (r.isDeleted) continue;-- const userName = getUserName(r.userID, r.anonUserID);- const email = getAvatarColorKey(r.userID, r.anonUserID);- const isMaskedEmail = isRegisteredUser(r.anonUserID);- const user: FeedUser = {- userID: r.userID,- anonUserID: r.anonUserID,- userName,- email,- isMaskedEmail,- };-- if (r.fileID && !r.commentID) {- // Reaction on a file (photo/video)- const fileID = r.fileID;- const existing = fileLikes.get(fileID);- if (existing) {- existing.users.push(user);- if (r.createdAt > existing.latestTimestamp) {- existing.latestTimestamp = r.createdAt;- // Move most recent user to front- existing.users.pop();- existing.users.unshift(user);- }- } else {- fileLikes.set(fileID, {- users: [user],- latestTimestamp: r.createdAt,- isVideo: isVideo(fileID),- });- }- } else if (r.commentID) {- // Reaction on a comment (treat reply likes as comment likes)- const commentID = r.commentID;- // Look up fileID from comment if not present in reaction- const fileID = r.fileID || commentFileIDMap.get(commentID);- const existing = commentLikes.get(commentID);- if (existing) {- existing.users.push(user);- if (r.createdAt > existing.latestTimestamp) {- existing.latestTimestamp = r.createdAt;- existing.users.pop();- existing.users.unshift(user);- }- } else {- commentLikes.set(commentID, {- users: [user],- latestTimestamp: r.createdAt,- fileID,- });- }- }- }-- // Add grouped file likes to feed- for (const [fileID, data] of fileLikes) {- feedItems.push({- id: `liked_file_${fileID}`,- type: data.isVideo ? "liked_video" : "liked_photo",- fileID,- thumbnailURL: getThumbnailURL(fileID),- timestamp: data.latestTimestamp,- users: data.users,- });- }-- // Add grouped comment likes to feed (includes reply likes)- for (const [commentID, data] of commentLikes) {- feedItems.push({- id: `liked_comment_${commentID}`,- type: "liked_comment",- commentID,- fileID: data.fileID,- thumbnailURL: getThumbnailURL(data.fileID),- timestamp: data.latestTimestamp,- users: data.users,- });- }-- // Sort by timestamp (newest first)- return feedItems.sort((a, b) => b.timestamp - a.timestamp);-};--/**- * Get the action text for a feed item.- */-const getActionText = (item: PublicFeedItem): string => {- switch (item.type) {- case "liked_photo":- return t("liked_a_photo");- case "liked_video":- return t("liked_a_video");- case "commented_photo":- return t("commented_on_a_photo");- case "commented_video":- return t("commented_on_a_video");- case "replied_comment":- return t("replied_to_a_comment");- case "liked_comment":- return t("liked_a_comment");- }-};--/**- * Get the users string for display (e.g., "John and 2 others").- */-const getUsersDisplayText = (users: FeedUser[]): string => {- if (users.length === 0) return "";- const firstName = getUserDisplayName(- users[0]!.userID,- users[0]!.userName,- users[0]!.anonUserID,- );- if (users.length === 1) {- return firstName;- }- const othersCount = users.length - 1;- return `${firstName} and ${othersCount} ${othersCount === 1 ? "other" : "others"}`;-};--/**- * Get the icon component for a feed item type.- */-const getFeedIcon = (- type: PublicFeedItem["type"],- heartStroke: string,-): React.ReactNode => {- switch (type) {- case "liked_photo":- case "liked_video":- return <LikedPhotoIcon />;- case "commented_photo":- case "commented_video":- return <CommentedPhotoIcon />;- case "replied_comment":- return <RepliedCommentIcon />;- case "liked_comment":- return <LikedCommentIcon heartStroke={heartStroke} />;- }-};--// =============================================================================-// Feed Item Row Component-// =============================================================================--interface FeedItemRowProps {- item: PublicFeedItem;- onClick?: () => void;-}--/**- * Get the users array from a feed item.- */-const getFeedItemUsers = (item: PublicFeedItem): FeedUser[] => {- switch (item.type) {- case "commented_photo":- case "commented_video":- case "replied_comment":- return [item.user];- case "liked_photo":- case "liked_video":- case "liked_comment":- return item.users;- }-};--/**- * A single row in the feed showing an action.- */-const FeedItemRow: React.FC<FeedItemRowProps> = ({ item, onClick }) => {- const { mode, systemMode } = useColorScheme();- const users = getFeedItemUsers(item);-- const displayText = getUsersDisplayText(users);- const actionText = getActionText(item);- const resolvedMode = mode === "system" ? systemMode : mode;- const heartStroke = resolvedMode === "dark" ? "#1b1b1b" : "white";-- return (- <FeedItemContainer onClick={onClick}>- <IconContainer>{getFeedIcon(item.type, heartStroke)}</IconContainer>- <FeedItemContent>- <AvatarStack>- {users.slice(0, 3).map((user, index) => {- const displayName = getUserDisplayName(- user.userID,- user.userName,- user.anonUserID,- );- return (- <StyledAvatar- key={`${user.userID}-${user.anonUserID ?? index}`}- sx={{- zIndex: users.length - index,- bgcolor: getAvatarColor(user.email),- color: "#fff",- }}- >- {user.isMaskedEmail ? (- <PersonIcon />- ) : (- (displayName[0]?.toUpperCase() ?? "A")- )}- </StyledAvatar>- );- })}- </AvatarStack>- <UserNameText>{displayText}</UserNameText>- <ActionText>{actionText}</ActionText>- </FeedItemContent>- {item.thumbnailURL && (- <ThumbnailImage src={item.thumbnailURL} alt="" />- )}- </FeedItemContainer>- );-};--// =============================================================================-// Main Component-// =============================================================================--/**- * Extracts navigation info from a feed item for click handling.- */-const getFeedItemClickInfo = (- item: PublicFeedItem,-): PublicFeedItemClickInfo => {- switch (item.type) {- case "liked_photo":- case "liked_video":- return { type: item.type, fileID: item.fileID };- case "commented_photo":- case "commented_video":- return {- type: item.type,- fileID: item.fileID,- commentID: item.commentID,- };- case "replied_comment":- return {- type: item.type,- fileID: item.fileID!,- commentID: item.replyID,- };- case "liked_comment":- return {- type: item.type,- fileID: item.fileID!,- commentID: item.commentID,- };- }-};--/**- * A sidebar panel for displaying the activity feed for a public album.- */-export const PublicFeedSidebar: React.FC<PublicFeedSidebarProps> = ({- open,- onClose,- files = [],- credentials,- collectionKey,- onItemClick,-}) => {- const [thumbnailCache, setThumbnailCache] = useState<ThumbnailCache>(- new Map(),- );- const [fileTypeCache, setFileTypeCache] = useState<FileTypeCache>(- new Map(),- );- const [comments, setComments] = useState<PublicFeedComment[]>([]);- const [reactions, setReactions] = useState<PublicFeedReaction[]>([]);- const [maskedEmails, setMaskedEmails] = useState<Map<number, string>>(- new Map(),- );- const [anonUserNames, setAnonUserNames] = useState<Map<string, string>>(- new Map(),- );- const [isLoading, setIsLoading] = useState(false);-- // Build file type cache from files- useEffect(() => {- const cache = new Map<number, number>();- for (const file of files) {- cache.set(file.id, file.metadata.fileType);- }- setFileTypeCache(cache);- }, [files]);-- // Load thumbnails for files that have reactions/comments- useEffect(() => {- const loadThumbnails = async () => {- // Get unique file IDs from comments and reactions- const fileIDsWithActivity = new Set<number>();- for (const c of comments) {- if (c.fileID) fileIDsWithActivity.add(c.fileID);- }- for (const r of reactions) {- if (r.fileID) fileIDsWithActivity.add(r.fileID);- }-- // Find matching files- const filesToLoad = files.filter((f) =>- fileIDsWithActivity.has(f.id),- );-- const newCache = new Map<number, string>();- for (const file of filesToLoad) {- try {- const url =- await downloadManager.renderableThumbnailURL(file);- if (url) {- newCache.set(file.id, url);- }- } catch {- // Ignore thumbnail loading errors- }- }- setThumbnailCache(newCache);- };-- if (open && (comments.length > 0 || reactions.length > 0)) {- void loadThumbnails();- }- }, [open, comments, reactions, files]);-- // Polling interval for refreshing feed data (5 seconds)- const FEED_REFRESH_INTERVAL_MS = 5_000;-- // Refresh social data (used for periodic refresh - excludes masked emails)- const refreshSocialData = useCallback(async () => {- try {- const [feedData, anonProfiles] = await Promise.all([- getPublicAlbumFeed(credentials, collectionKey),- getPublicAnonProfiles(credentials, collectionKey),- ]);- setComments(feedData.comments);- setReactions(feedData.reactions);- setAnonUserNames(anonProfiles);- // Note: Masked emails for registered participants are fetched only- // on initial load since they rarely change during a session.- } catch (e) {- log.error("Failed to refresh public album feed", e);- }- }, [credentials, collectionKey]);-- // Initial fetch when sidebar opens (includes masked emails)- useEffect(() => {- if (!open) return;-- const fetchInitialData = async () => {- try {- const [feedData, anonProfiles, participantEmails] =- await Promise.all([- getPublicAlbumFeed(credentials, collectionKey),- getPublicAnonProfiles(credentials, collectionKey),- getPublicParticipantsMaskedEmails(credentials),- ]);- setComments(feedData.comments);- setReactions(feedData.reactions);- setAnonUserNames(anonProfiles);- setMaskedEmails(participantEmails);- } catch (e) {- log.error("Failed to fetch public album feed", e);- }- };-- setIsLoading(true);- void fetchInitialData().finally(() => setIsLoading(false));- }, [open, credentials, collectionKey]);-- // Periodic refresh while sidebar is open- useInterval(- refreshSocialData,- open && !isLoading ? FEED_REFRESH_INTERVAL_MS : null,- );-- const feedItems = useMemo(- () =>- processFeedItems(- comments,- reactions,- thumbnailCache,- fileTypeCache,- maskedEmails,- anonUserNames,- ),- [- comments,- reactions,- thumbnailCache,- fileTypeCache,- maskedEmails,- anonUserNames,- ],- );-- return (- <SidebarDrawer open={open} onClose={onClose} anchor="right">- <DrawerContentWrapper>- <Header>- <Typography- sx={(theme) => ({- color: "#000",- fontWeight: 600,- ...theme.applyStyles("dark", { color: "#fff" }),- })}- >- {t("feed")}- </Typography>- <CloseButton onClick={onClose}>- <CloseIcon sx={{ fontSize: 22 }} />- </CloseButton>- </Header>-- <ContentContainer>- {isLoading ? (- <LoadingContainer>- <CircularProgress size={24} />- </LoadingContainer>- ) : feedItems.length === 0 ? (- <EmptyStateText>{t("no_activity_yet")}</EmptyStateText>- ) : (- feedItems.map((item) => (- <FeedItemRow- key={item.id}- item={item}- onClick={- onItemClick- ? () => {- onItemClick(- getFeedItemClickInfo(item),- );- }- : undefined- }- />- ))- )}- </ContentContainer>- </DrawerContentWrapper>- </SidebarDrawer>- );-};--// =============================================================================-// Styled Components-// =============================================================================--// Drawer & Layout-const SidebarDrawer = styled(Drawer)(({ theme }) => ({- zIndex: 2100, // Above TripLayout nav buttons (z-index: 2000)- "& .MuiDrawer-paper": {- width: "23vw",- minWidth: "520px",- maxWidth: "calc(100% - 32px)",- height: "calc(100% - 32px)",- margin: "16px",- borderRadius: "36px",- backgroundColor: "#FAFAFA",- padding: "24px 24px 32px 24px",- boxShadow: "none",- border: "1px solid #E0E0E0",- display: "flex",- flexDirection: "column",- overflow: "visible",- "@media (max-width: 450px)": {- width: "100%",- minWidth: "unset",- maxWidth: "100%",- height: "100%",- margin: 0,- borderRadius: 0,- },- ...theme.applyStyles("dark", {- backgroundColor: "#1b1b1b",- border: "1px solid rgba(255, 255, 255, 0.18)",- }),- },- "& .MuiBackdrop-root": { backgroundColor: "rgba(0, 0, 0, 0.65)" },-}));--const DrawerContentWrapper = styled(Box)(() => ({- position: "relative",- display: "flex",- flexDirection: "column",- flex: 1,- minHeight: 0,-}));--const Header = styled(Stack)(() => ({- flexDirection: "row",- alignItems: "center",- justifyContent: "space-between",- marginBottom: 48,-}));--const CloseButton = styled(IconButton)(({ theme }) => ({- backgroundColor: "#F5F5F7",- color: "#000",- padding: "8px",- "&:hover": { backgroundColor: "#E5E5E7" },- ...theme.applyStyles("dark", {- backgroundColor: "rgba(255, 255, 255, 0.12)",- color: "#fff",- "&:hover": { backgroundColor: "rgba(255, 255, 255, 0.16)" },- }),-}));--const ContentContainer = styled(Box)(({ theme }) => ({- flex: 1,- overflow: "auto",- marginRight: -24,- paddingRight: 24,- "&::-webkit-scrollbar": { width: "6px" },- "&::-webkit-scrollbar-track": { background: "transparent" },- "&::-webkit-scrollbar-thumb": {- background: "rgba(0, 0, 0, 0.2)",- borderRadius: "3px",- },- scrollbarWidth: "thin",- scrollbarColor: "rgba(0, 0, 0, 0.2) transparent",- ...theme.applyStyles("dark", {- "&::-webkit-scrollbar-thumb": {- background: "rgba(255, 255, 255, 0.2)",- },- scrollbarColor: "rgba(255, 255, 255, 0.2) transparent",- }),-}));--// Feed Item Components-const FeedItemContainer = styled(Box)(({ theme }) => ({- display: "flex",- alignItems: "flex-start",- gap: 12,- marginBottom: 40,- cursor: "pointer",- position: "relative",- "&:not(:last-child)::before": {- content: '""',- position: "absolute",- left: 16,- top: 33,- bottom: -40,- width: 2,- backgroundImage:- "repeating-linear-gradient(to bottom, #E6E6E6 0px, #E6E6E6 8px, transparent 8px, transparent 16px)",- borderRadius: 1,- ...theme.applyStyles("dark", {- backgroundImage:- "repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.18) 0px, rgba(255, 255, 255, 0.18) 8px, transparent 8px, transparent 16px)",- }),- },- "&:last-child": { marginBottom: 0 },-}));--const IconContainer = styled(Box)(({ theme }) => ({- display: "flex",- alignItems: "center",- justifyContent: "center",- width: 33,- height: 33,- flexShrink: 0,- backgroundColor: "#fff",- borderRadius: "50%",- position: "relative",- zIndex: 1,- ...theme.applyStyles("dark", { backgroundColor: "#2a2a2a" }),-}));--const FeedItemContent = styled(Box)(() => ({- display: "flex",- flexDirection: "column",- gap: 4,- flex: 1,- minWidth: 0,-}));--const AvatarStack = styled(Box)(() => ({- display: "flex",- flexDirection: "row",- alignItems: "center",-}));--const StyledAvatar = styled(Avatar)(({ theme }) => ({- width: 32,- height: 32,- fontSize: 14,- fontWeight: 600,- border: "2px solid #FAFAFA",- marginLeft: -8,- "&:first-of-type": { marginLeft: 0 },- ...theme.applyStyles("dark", { border: "2px solid #1b1b1b" }),-}));--const UserNameText = styled(Typography)(({ theme }) => ({- fontWeight: 600,- fontSize: 14,- color: "#000",- whiteSpace: "nowrap",- overflow: "hidden",- textOverflow: "ellipsis",- ...theme.applyStyles("dark", { color: "#fff" }),-}));--const ActionText = styled(Typography)(({ theme }) => ({- fontSize: 13,- color: "#666",- whiteSpace: "nowrap",- overflow: "hidden",- textOverflow: "ellipsis",- ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.7)" }),-}));--const ThumbnailImage = styled("img")(() => ({- width: 76,- height: 76,- borderRadius: 8,- objectFit: "cover",- flexShrink: 0,-}));--const LoadingContainer = styled(Box)(() => ({- display: "flex",- justifyContent: "center",- alignItems: "center",- height: "100%",- // Offset for header (marginBottom: 48) + padding diff (32-24=8) = 56, halved- marginTop: -28,-}));--const EmptyStateText = styled(Typography)(({ theme }) => ({- display: "flex",- justifyContent: "center",- alignItems: "center",- height: "100%",- // Offset for header (marginBottom: 48) + padding diff (32-24=8) = 56, halved- marginTop: -28,- color: "#666",- ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.6)" }),-}));diff --git a/web/packages/gallery/components/viewer/PublicLikeModal.tsx b/web/packages/gallery/components/viewer/PublicLikeModal.tsxdeleted file mode 100644index 9ac5430118..0000000000--- a/web/packages/gallery/components/viewer/PublicLikeModal.tsx+++ /dev/null@@ -1,292 +0,0 @@-import CloseIcon from "@mui/icons-material/Close";-import {- Box,- Button,- Dialog,- IconButton,- styled,- Typography,-} from "@mui/material";-import { type ModalVisibilityProps } from "ente-base/components/utils/modal";-import { t } from "i18next";-import React from "react";--// =============================================================================-// Icons-// =============================================================================--const LikeIllustration: React.FC = () => (- <svg- width="126"- height="121"- viewBox="0 0 126 121"- fill="none"- xmlns="http://www.w3.org/2000/svg"- >- <path- d="M84.7129 23.0781C96.7222 23.0784 105.29 32.8476 105.29 44.499C105.29 53.3449 99.7258 62.2116 93.4453 69.4932C87.0622 76.8936 79.4391 83.2238 74.3574 87.0557C69.973 90.3616 64.031 90.3614 59.6465 87.0557C54.5648 83.2238 46.9408 76.8937 40.5576 69.4932C34.2771 62.2116 28.7129 53.3449 28.7129 44.499C28.713 32.8474 37.2813 23.0781 49.291 23.0781C54.9545 23.0782 60.4297 24.9062 67.001 30.9004C73.5726 24.9056 79.0491 23.0781 84.7129 23.0781Z"- fill="#08C225"- stroke="#232323"- strokeWidth="5.73358"- strokeLinecap="round"- strokeLinejoin="round"- />- <mask- id="mask0_public_like"- style={{ maskType: "alpha" }}- maskUnits="userSpaceOnUse"- x="31"- y="25"- width="72"- height="62"- >- <path- d="M61.3721 84.7662C51.3787 77.2306 31.5801 60.0026 31.5801 44.4993C31.5801 34.2522 39.0372 25.9453 49.2909 25.9453C54.6041 25.9453 59.9173 27.7313 67.0016 34.8751C74.086 27.7313 79.3992 25.9453 84.7124 25.9453C94.9659 25.9453 102.423 34.2522 102.423 44.4993C102.423 60.0026 82.6247 77.2306 72.6312 84.7662C69.2683 87.3019 64.735 87.3019 61.3721 84.7662Z"- fill="#08C225"- />- </mask>- <g mask="url(#mask0_public_like)">- <path- d="M47.5975 41.0431C46.8515 39.3306 47.9859 37.1849 50.1312 36.2504C52.2765 35.316 54.6203 35.9467 55.3662 37.6591C56.1121 39.3716 54.9777 41.5173 52.8324 42.4518C50.6872 43.3862 48.3434 42.7555 47.5975 41.0431Z"- fill="white"- />- <path- d="M44.5677 45.0545C44.3136 44.4712 44.7025 43.7391 45.4364 43.4194C46.1704 43.0997 46.9713 43.3135 47.2254 43.8968C47.4795 44.4802 47.0906 45.2123 46.3567 45.532C45.6227 45.8517 44.8218 45.6379 44.5677 45.0545Z"- fill="white"- />- <path- d="M102.994 32.271C101.622 55.1395 78.9821 78.0073 50.9683 82.581C49.2531 88.2982 42.3926 93.7861 42.3926 95.1582C42.3926 96.5303 48.1097 107.926 50.9683 113.453L89.8447 101.447L115 66.5725C113.094 57.9969 106.196 31.3563 102.994 32.271Z"- fill="#46A030"- />- <path- d="M59.7039 28.2666C34.9591 23.1218 29.8137 47.7054 32.6723 55.1377L23.1143 51.7074C21.3992 47.3243 18.1976 37.9863 19.1123 35.6995C20.0271 33.4126 22.1615 16.833 23.1143 8.829L55.1302 3.68359L96.8651 13.9744C97.6274 18.1664 98.4659 26.8936 95.7217 28.2666C80.2855 22.5506 66.5644 33.9826 66.5644 33.4109C66.5644 32.9535 68.4701 30.5523 69.423 29.4089C66.3738 29.0281 60.1612 28.2666 59.7039 28.2666Z"- fill="white"- />- </g>- <path- d="M20.9639 58.8477C14.9399 61.182 10.9104 66.0874 11.263 71.48C10.9104 66.0874 6.28324 61.7544 -9.80907e-05 60.2184C6.02383 57.884 10.0533 52.9787 9.70073 47.5861C10.0533 52.9787 14.6805 57.3117 20.9639 58.8477Z"- fill="#08C225"- />- <path- d="M119.579 91.9746C111.591 92.7003 105.114 97.1692 103.689 103.722C105.114 97.1692 101.077 90.4145 94.1117 86.438C102.099 85.7122 108.576 81.2434 110.001 74.6902C108.576 81.2434 112.613 87.9981 119.579 91.9746Z"- fill="#08C225"- />- <path- d="M112.728 9.21189C108.334 9.91374 104.912 12.6353 104.37 16.3181C104.912 12.6353 102.421 9.04853 98.4114 7.10627C102.806 6.40442 106.228 3.68284 106.77 7.55054e-05C106.228 3.68284 108.719 7.26962 112.728 9.21189Z"- fill="#08C225"- />- </svg>-);--// =============================================================================-// Types-// =============================================================================--export interface PublicLikeModalProps extends ModalVisibilityProps {- /**- * Called when user clicks "Like anonymously".- */- onLikeAnonymously: () => void;- /**- * Called when user clicks "Join album to like".- */- onJoinAlbumToLike: () => void;- /**- * Whether the "Join album" option is enabled for this public link.- * When false, the "Join album and like" button will be hidden.- */- enableJoin?: boolean;-}--/**- * Modal dialog for liking a photo in a public album.- * Shows options to like anonymously or sign in to like.- */-export const PublicLikeModal: React.FC<PublicLikeModalProps> = ({- open,- onClose,- onLikeAnonymously,- onJoinAlbumToLike,- enableJoin = true,-}) => {- return (- <StyledDialog open={open} onClose={onClose}>- <DialogWrapper>- <CloseButton onClick={onClose}>- <CloseIcon sx={{ fontSize: 20 }} />- </CloseButton>-- <ContentContainer>- <IllustrationWrapper>- <LikeIllustration />- </IllustrationWrapper>-- <TitleSection>- <Title>{t("give_it_a_like")}</Title>- {enableJoin && (- <Subtitle>{t("public_like_subtitle")}</Subtitle>- )}- </TitleSection>-- <ButtonsSection sx={!enableJoin ? { mt: 4 } : undefined}>- {enableJoin ? (- <AnonymousButton- variant="outlined"- fullWidth- onClick={onLikeAnonymously}- >- {t("like_anonymously")}- </AnonymousButton>- ) : (- <SignInButton- variant="contained"- fullWidth- onClick={onLikeAnonymously}- >- {t("like_anonymously")}- </SignInButton>- )}- {enableJoin && (- <SignInButton- variant="contained"- fullWidth- onClick={onJoinAlbumToLike}- >- {t("join_album_and_like")}- </SignInButton>- )}- </ButtonsSection>- </ContentContainer>- </DialogWrapper>- </StyledDialog>- );-};--// =============================================================================-// Styled Components-// =============================================================================--const StyledDialog = styled(Dialog)(({ theme }) => ({- "& .MuiDialog-paper": {- width: 381,- maxWidth: "calc(100% - 32px)",- borderRadius: 28,- backgroundColor: "#fff",- padding: 0,- margin: 16,- overflow: "visible",- boxShadow: "none",- border: "1px solid #E0E0E0",- ...theme.applyStyles("dark", {- backgroundColor: "#1b1b1b",- border: "1px solid rgba(255, 255, 255, 0.18)",- }),- },- "& .MuiBackdrop-root": { backgroundColor: "rgba(0, 0, 0, 0.5)" },-}));--const DialogWrapper = styled(Box)(() => ({- position: "relative",- padding: "48px 16px 16px 16px",-}));--const CloseButton = styled(IconButton)(({ theme }) => ({- position: "absolute",- top: 11,- right: 12,- backgroundColor: "#FAFAFA",- color: "#000",- padding: 10,- "&:hover": { backgroundColor: "#F0F0F0" },- ...theme.applyStyles("dark", {- backgroundColor: "rgba(255, 255, 255, 0.12)",- color: "#fff",- "&:hover": { backgroundColor: "rgba(255, 255, 255, 0.16)" },- }),-}));--const ContentContainer = styled(Box)(() => ({- display: "flex",- flexDirection: "column",- alignItems: "center",- gap: 16,-}));--const IllustrationWrapper = styled(Box)(() => ({- display: "flex",- justifyContent: "center",- alignItems: "center",- marginBottom: 8,-}));--const TitleSection = styled(Box)(() => ({- display: "flex",- flexDirection: "column",- alignItems: "center",- gap: 9,- textAlign: "center",- marginBottom: 16,-}));--const Title = styled(Typography)(({ theme }) => ({- fontWeight: 600,- fontSize: 24,- lineHeight: "28px",- letterSpacing: "-0.48px",- color: "#000",- ...theme.applyStyles("dark", { color: "#fff" }),-}));--const Subtitle = styled(Typography)(({ theme }) => ({- fontWeight: 500,- fontSize: 14,- lineHeight: "20px",- color: "#666666",- maxWidth: 240,- ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.7)" }),-}));--const ButtonsSection = styled(Box)(() => ({- width: "100%",- display: "flex",- flexDirection: "column",- gap: 12,-}));--const AnonymousButton = styled(Button)(({ theme }) => ({- display: "flex",- padding: "20px 16px",- justifyContent: "center",- alignItems: "center",- gap: 8,- flex: "1 0 0",- borderRadius: 20,- backgroundColor: "rgba(0, 0, 0, 0.04)",- border: "none",- fontSize: 16,- fontWeight: 500,- textTransform: "none",- color: "#000",- "&:hover": { backgroundColor: "rgba(0, 0, 0, 0.08)", border: "none" },- ...theme.applyStyles("dark", {- backgroundColor: "rgba(255, 255, 255, 0.08)",- color: "#fff",- "&:hover": { backgroundColor: "rgba(255, 255, 255, 0.12)" },- }),-}));--const SignInButton = styled(Button)(() => ({- display: "flex",- padding: "20px 16px",- justifyContent: "center",- alignItems: "center",- gap: 8,- flex: "1 0 0",- borderRadius: 20,- backgroundColor: "#08C225",- fontSize: 16,- fontWeight: 500,- textTransform: "none",- color: "#fff",- "&:hover": { backgroundColor: "#07A820" },-}));diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.tsindex 0d97b32f03..867500c3ad 100644--- a/web/packages/gallery/components/viewer/photoswipe.ts+++ b/web/packages/gallery/components/viewer/photoswipe.ts@@ -136,22 +136,15 @@ type FileViewerPhotoSwipeOptions = Pick<* {@link showFavorite} file annotation are true.*/haveUser: boolean;- /**- * `true` when viewing a public album.- */- isPublicAlbum: boolean;/*** `true` if the like and comment action buttons should be shown.** These buttons are shown only when viewing files in a shared album- * (incoming or outgoing) or in a public album.+ * (incoming or outgoing).*/showSocialButtons: boolean;/**- * `true` if comments are enabled on the public link.- *- * When `false`, the comment button will be hidden even if- * {@link showSocialButtons} is `true`.+ * `true` if the comments and reactions controls should be enabled.*/enableComment: boolean;/**@@ -251,7 +244,6 @@ export class FileViewerPhotoSwipe {constructor({initialIndex,haveUser,- isPublicAlbum,showSocialButtons,enableComment,showFullscreenButton,@@ -315,9 +307,7 @@ export class FileViewerPhotoSwipe {// Use "pswp-ente" as the main class name. Note that this is not// necessary, we could've target the "pswp" class too in our CSS// since we only have a single PhotoSwipe instance.- mainClass: isPublicAlbum- ? "pswp-ente pswp-ente-public-album"- : "pswp-ente",+ mainClass: "pswp-ente",closeTitle: t("close"),zoomTitle: t("zoom"),arrowPrevTitle: t("previous"),@@ -1324,23 +1314,6 @@ export class FileViewerPhotoSwipe {// Register our custom elements...- if (isPublicAlbum) {- ui.registerElement({- name: "ente-logo",- order: 5,- isButton: true,- title: "Ente",- html: publicAlbumEnteLogoHTML(),- onClick: () => {- window.open(- "https://ente.com",- "_blank",- "noopener,noreferrer",- );- },- });- }-ui.registerElement({name: "live",title: t("live"),@@ -1568,17 +1541,13 @@ export class FileViewerPhotoSwipe {// initialization before the first slide is shown.if (!_currentAnnotatedFile) return;// Show buttons if: static showSocialButtons is true- // (public album) OR delegate says this file should- // show buttons (file in shared collection).- // For public albums (no logged-in user), also check- // if comments are enabled on the public link.+ // OR delegate says this file should show buttons+ // (file in shared collection).const af = currentAnnotatedFile();const baseShow =showSocialButtons ||delegate.shouldShowSocialButtons(af);- // For public albums (!haveUser), also require enableComment- const shouldShow =- baseShow && (haveUser || enableComment);+ const shouldShow = baseShow && enableComment;actionButtonsEl.style.display = shouldShow? "flex": "none";@@ -2135,12 +2104,6 @@ const bottomRightControlsHTML = () => `</div>`;-const publicAlbumEnteLogoHTML = () => `-<svg class="pswp__ente-logo-svg" viewBox="0 0 43 13" fill="currentColor" xmlns="http://www.w3.org/2000/svg">- <path d="M6.102 12.144C4.998 12.144 4.026 11.928 3.186 11.496C2.358 11.064 1.716 10.476 1.26 9.732C0.804 8.976 0.576 8.118 0.576 7.158C0.576 6.186 0.798 5.328 1.242 4.584C1.698 3.828 2.316 3.24 3.096 2.82C3.876 2.388 4.758 2.172 5.742 2.172C6.69 2.172 7.542 2.376 8.298 2.784C9.066 3.18 9.672 3.756 10.116 4.512C10.56 5.256 10.782 6.15 10.782 7.194C10.782 7.302 10.776 7.428 10.764 7.572C10.752 7.704 10.74 7.83 10.728 7.95H2.862V6.312H9.252L8.172 6.798C8.172 6.294 8.07 5.856 7.866 5.484C7.662 5.112 7.38 4.824 7.02 4.62C6.66 4.404 6.24 4.296 5.76 4.296C5.28 4.296 4.854 4.404 4.482 4.62C4.122 4.824 3.84 5.118 3.636 5.502C3.432 5.874 3.33 6.318 3.33 6.834V7.266C3.33 7.794 3.444 8.262 3.672 8.67C3.912 9.066 4.242 9.372 4.662 9.588C5.094 9.792 5.598 9.894 6.174 9.894C6.69 9.894 7.14 9.816 7.524 9.66C7.92 9.504 8.28 9.27 8.604 8.958L10.098 10.578C9.654 11.082 9.096 11.472 8.424 11.748C7.752 12.012 6.978 12.144 6.102 12.144ZM18.5375 2.172C19.3055 2.172 19.9895 2.328 20.5895 2.64C21.2015 2.94 21.6815 3.408 22.0295 4.044C22.3775 4.668 22.5515 5.472 22.5515 6.456V12H19.7435V6.888C19.7435 6.108 19.5695 5.532 19.2215 5.16C18.8855 4.788 18.4055 4.602 17.7815 4.602C17.3375 4.602 16.9355 4.698 16.5755 4.89C16.2275 5.07 15.9515 5.352 15.7475 5.736C15.5555 6.12 15.4595 6.612 15.4595 7.212V12H12.6515V2.316H15.3335V4.998L14.8295 4.188C15.1775 3.54 15.6755 3.042 16.3235 2.694C16.9715 2.346 17.7095 2.172 18.5375 2.172ZM29.0568 12.144C27.9168 12.144 27.0288 11.856 26.3928 11.28C25.7568 10.692 25.4388 9.822 25.4388 8.67V0.174H28.2468V8.634C28.2468 9.042 28.3548 9.36 28.5708 9.588C28.7868 9.804 29.0808 9.912 29.4528 9.912C29.8968 9.912 30.2748 9.792 30.5868 9.552L31.3428 11.532C31.0548 11.736 30.7068 11.892 30.2988 12C29.9028 12.096 29.4888 12.144 29.0568 12.144ZM23.9448 4.692V2.532H30.6588V4.692H23.9448ZM37.4262 12.144C36.3222 12.144 35.3502 11.928 34.5102 11.496C33.6822 11.064 33.0402 10.476 32.5842 9.732C32.1282 8.976 31.9002 8.118 31.9002 7.158C31.9002 6.186 32.1222 5.328 32.5662 4.584C33.0222 3.828 33.6402 3.24 34.4202 2.82C35.2002 2.388 36.0822 2.172 37.0662 2.172C38.0142 2.172 38.8662 2.376 39.6222 2.784C40.3902 3.18 40.9962 3.756 41.4402 4.512C41.8842 5.256 42.1062 6.15 42.1062 7.194C42.1062 7.302 42.1002 7.428 42.0882 7.572C42.0762 7.704 42.0642 7.83 42.0522 7.95H34.1862V6.312H40.5762L39.4962 6.798C39.4962 6.294 39.3942 5.856 39.1902 5.484C38.9862 5.112 38.7042 4.824 38.3442 4.62C37.9842 4.404 37.5642 4.296 37.0842 4.296C36.6042 4.296 36.1782 4.404 35.8062 4.62C35.4462 4.824 35.1642 5.118 34.9602 5.502C34.7562 5.874 34.6542 6.318 34.6542 6.834V7.266C34.6542 7.794 34.7682 8.262 34.9962 8.67C35.2362 9.066 35.5662 9.372 35.9862 9.588C36.4182 9.792 36.9222 9.894 37.4982 9.894C38.0142 9.894 38.4642 9.816 38.8482 9.66C39.2442 9.504 39.6042 9.27 39.9282 8.958L41.4222 10.578C40.9782 11.082 40.4202 11.472 39.7482 11.748C39.0762 12.012 38.3022 12.144 37.4262 12.144Z" />-</svg>-`;-/*** Truncate caption text to 154 characters.*diff --git a/web/packages/new/albums/components/UploaderNameInput.tsx b/web/packages/new/albums/components/UploaderNameInput.tsxdeleted file mode 100644index 78cf0a94e2..0000000000--- a/web/packages/new/albums/components/UploaderNameInput.tsx+++ /dev/null@@ -1,381 +0,0 @@-import { User03Icon } from "@hugeicons/core-free-icons";-import { HugeiconsIcon } from "@hugeicons/react";-import CloseIcon from "@mui/icons-material/Close";-import {- Box,- Button,- Dialog,- IconButton,- styled,- TextField,- Typography,-} from "@mui/material";-import type { ModalVisibilityProps } from "ente-base/components/utils/modal";-import log from "ente-base/log";-import { useFormik } from "formik";-import { t } from "i18next";-import React from "react";--// =============================================================================-// Sparkle Icons-// =============================================================================--const SparkleTopRight: React.FC = () => (- <svg- width="14"- height="16"- viewBox="0 0 20 22"- fill="none"- xmlns="http://www.w3.org/2000/svg"- style={{ position: "absolute", top: 0, right: 8 }}- >- <path- d="M19.728 9.21189C15.334 9.91374 11.912 12.6353 11.37 16.3181C11.912 12.6353 9.421 9.04853 5.4114 7.10627C9.806 6.40442 13.228 3.68284 13.77 7.55054e-05C13.228 3.68284 15.719 7.26962 19.728 9.21189Z"- fill="#08C225"- />- </svg>-);--const SparkleBottomRight: React.FC = () => (- <svg- width="22"- height="26"- viewBox="0 0 32 36"- fill="none"- xmlns="http://www.w3.org/2000/svg"- style={{ position: "absolute", bottom: 0, right: -8 }}- >- <path- d="M31.579 17.9746C23.591 18.7003 17.114 23.1692 15.689 29.722C17.114 23.1692 13.077 16.4145 6.1117 12.438C14.099 11.7122 20.576 7.2434 22.001 0.6902C20.576 7.2434 24.613 13.9981 31.579 17.9746Z"- fill="#08C225"- />- </svg>-);--const SparkleBottomLeft: React.FC = () => (- <svg- width="18"- height="16"- viewBox="0 0 26 22"- fill="none"- xmlns="http://www.w3.org/2000/svg"- style={{ position: "absolute", bottom: 8, left: -8 }}- >- <path- d="M25.9639 10.8477C19.9399 13.182 15.9104 18.0874 16.263 23.48C15.9104 18.0874 11.2832 13.7544 4.99991 12.2184C11.0238 9.884 15.0533 4.9787 14.7007 -0.4139C15.0533 4.9787 19.6805 9.3117 25.9639 10.8477Z"- fill="#08C225"- />- </svg>-);--// =============================================================================-// Types-// =============================================================================--type UploaderNameInputProps = ModalVisibilityProps & {- /**- * The existing uploader name to prefill.- */- uploaderName: string;- /**- * Count of the number of files that the uploader is trying to upload.- */- uploadFileCount: number;- /**- * Callback invoked when the user presses submit after entering a name.- */- onSubmit: (name: string) => void | Promise<void>;-};--/**- * A dialog asking the uploader to a public album to provide their name so that- * other folks can know who uploaded a given photo in the shared album.- */-export const UploaderNameInput: React.FC<UploaderNameInputProps> = ({- open,- onClose,- uploaderName,- uploadFileCount,- onSubmit,-}) => {- return (- <StyledDialog open={open} onClose={onClose}>- <DialogWrapper>- <CloseButton onClick={onClose}>- <CloseIcon sx={{ fontSize: 20 }} />- </CloseButton>-- <ContentContainer>- <IllustrationContainer>- <SparkleTopRight />- <SparkleBottomRight />- <SparkleBottomLeft />- <IllustrationWrapper>- <HugeiconsIcon- icon={User03Icon}- size={28}- color="#fff"- strokeWidth={1.8}- />- </IllustrationWrapper>- </IllustrationContainer>-- <TitleSection>- <Title>{t("enter_name")}</Title>- <Subtitle>{t("uploader_name_hint")}</Subtitle>- </TitleSection>-- <UploaderNameInputForm- {...{- onClose,- uploaderName,- uploadFileCount,- onSubmit,- }}- />- </ContentContainer>- </DialogWrapper>- </StyledDialog>- );-};--/**- * The form that obtains the textual input of the uploader name.- *- * It is kept as a separate component so that it gets recreated on prop changes- * (e.g. uploaderName changes).- */-export const UploaderNameInputForm: React.FC<- Omit<UploaderNameInputProps, "open">-> = ({ onClose, uploaderName, uploadFileCount, onSubmit }) => {- const formik = useFormik({- initialValues: { value: uploaderName },- onSubmit: async (values, { setFieldError }) => {- const value = values.value;- const setValueFieldError = (message: string) =>- setFieldError("value", message);-- if (!value) {- setValueFieldError(t("required"));- return;- }- try {- await onSubmit(value);- onClose();- } catch (e) {- log.error(`Failed to submit input ${value}`, e);- setValueFieldError(t("generic_error"));- }- },- });-- return (- <FormContainer onSubmit={formik.handleSubmit}>- <StyledTextField- name="value"- value={formik.values.value}- onChange={formik.handleChange}- type="text"- variant="standard"- fullWidth- autoFocus- hiddenLabel- aria-label={t("name")}- placeholder={t("name_placeholder")}- disabled={formik.isSubmitting}- error={!!formik.errors.value}- helperText={formik.errors.value}- />- <ButtonsSection>- <SubmitButton- type="submit"- variant="contained"- disabled={- formik.isSubmitting || !formik.values.value.trim()- }- hasName={!!formik.values.value.trim()}- >- {formik.isSubmitting- ? t("loading")- : t("add_photos_count", { count: uploadFileCount })}- </SubmitButton>- </ButtonsSection>- </FormContainer>- );-};--// =============================================================================-// Styled Components-// =============================================================================--const StyledDialog = styled(Dialog)(({ theme }) => ({- "& .MuiDialog-paper": {- width: 381,- maxWidth: "calc(100% - 32px)",- borderRadius: 28,- backgroundColor: "#fff",- padding: 0,- margin: 16,- overflow: "visible",- boxShadow: "none",- border: "1px solid #E0E0E0",- ...theme.applyStyles("dark", {- backgroundColor: "#1b1b1b",- border: "1px solid rgba(255, 255, 255, 0.18)",- }),- },- "& .MuiBackdrop-root": { backgroundColor: "rgba(0, 0, 0, 0.5)" },-}));--const DialogWrapper = styled(Box)(() => ({- position: "relative",- padding: "48px 16px 16px 16px",-}));--const CloseButton = styled(IconButton)(({ theme }) => ({- position: "absolute",- top: 11,- right: 12,- backgroundColor: "#FAFAFA",- color: "#000",- padding: 10,- "&:hover": { backgroundColor: "#F0F0F0" },- ...theme.applyStyles("dark", {- backgroundColor: "rgba(255, 255, 255, 0.12)",- color: "#fff",- "&:hover": { backgroundColor: "rgba(255, 255, 255, 0.16)" },- }),-}));--const ContentContainer = styled(Box)(() => ({- display: "flex",- flexDirection: "column",- alignItems: "center",- gap: 16,-}));--const IllustrationContainer = styled(Box)(() => ({- position: "relative",- width: 100,- height: 70,- display: "flex",- justifyContent: "center",- alignItems: "center",- marginBottom: 8,-}));--const IllustrationWrapper = styled(Box)(() => ({- display: "flex",- justifyContent: "center",- alignItems: "center",- width: 52,- height: 52,- borderRadius: "50%",- backgroundColor: "#08C225",-}));--const TitleSection = styled(Box)(() => ({- display: "flex",- flexDirection: "column",- alignItems: "center",- gap: 9,- textAlign: "center",- marginBottom: 8,-}));--const Title = styled(Typography)(({ theme }) => ({- fontWeight: 600,- fontSize: 24,- lineHeight: "28px",- letterSpacing: "-0.48px",- color: "#000",- ...theme.applyStyles("dark", { color: "#fff" }),-}));--const Subtitle = styled(Typography)(({ theme }) => ({- fontWeight: 500,- fontSize: 14,- lineHeight: "20px",- color: "#666666",- maxWidth: "75%",- ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.7)" }),-}));--const FormContainer = styled("form")(() => ({- width: "100%",- display: "flex",- flexDirection: "column",- gap: 16,-}));--const StyledTextField = styled(TextField)(({ theme }) => ({- "& .MuiInput-root": {- height: 54,- backgroundColor: "#FAFAFA",- borderRadius: 12,- "&::before": { borderBottom: "1px solid #E0E0E0" },- "&::after": { borderBottom: "2px solid #08C225" },- "&:hover:not(.Mui-disabled)::before": {- borderBottom: "1px solid #BDBDBD",- },- },- "& .MuiInputBase-input": {- padding: "0 16px",- height: "100%",- boxSizing: "border-box",- fontSize: 16,- color: "#000",- "&::placeholder": { color: "#999", opacity: 1 },- },- ...theme.applyStyles("dark", {- "& .MuiInput-root": {- backgroundColor: "rgba(255, 255, 255, 0.08)",- "&::before": { borderBottom: "1px solid rgba(255, 255, 255, 0.3)" },- "&:hover:not(.Mui-disabled)::before": {- borderBottom: "1px solid rgba(255, 255, 255, 0.5)",- },- },- "& .MuiInputBase-input": {- color: "#fff",- "&::placeholder": { color: "rgba(255, 255, 255, 0.5)" },- },- }),-}));--const ButtonsSection = styled(Box)(() => ({- width: "100%",- display: "flex",- flexDirection: "row",- gap: 12,-}));--const SubmitButton = styled(Button)<{ hasName: boolean }>(- ({ hasName, theme }) => ({- display: "flex",- padding: "16px",- justifyContent: "center",- alignItems: "center",- gap: 8,- flex: 1,- borderRadius: 20,- backgroundColor: hasName ? "#08C225" : "rgba(0, 0, 0, 0.04)",- fontSize: 16,- fontWeight: 500,- textTransform: "none",- color: hasName ? "#fff" : "#999",- boxShadow: "none",- "&:hover": {- backgroundColor: hasName ? "#07A820" : "rgba(0, 0, 0, 0.08)",- boxShadow: "none",- },- ...theme.applyStyles("dark", {- backgroundColor: hasName ? "#08C225" : "rgba(255, 255, 255, 0.08)",- color: hasName ? "#fff" : "rgba(255, 255, 255, 0.5)",- "&:hover": {- backgroundColor: hasName- ? "#07A820"- : "rgba(255, 255, 255, 0.12)",- },- }),- }),-);diff --git a/web/packages/new/albums/services/public-albums-fdb.ts b/web/packages/new/albums/services/public-albums-fdb.tsdeleted file mode 100644index 82b6ff5e13..0000000000--- a/web/packages/new/albums/services/public-albums-fdb.ts+++ /dev/null@@ -1,306 +0,0 @@-/**- * @file Public albums app specific files DB. See: [Note: Files DB].- */--import {- LocalCollections,- LocalEnteFiles,- localForage,- LocalTimestamp,- transformFilesIfNeeded,-} from "ente-gallery/services/files-db";-import { type Collection } from "ente-media/collection";-import type { EnteFile } from "ente-media/file";-import { nullToUndefined } from "ente-utils/transform";-import { z } from "zod";--/**- * Return all public collections present in our local database.- *- * Use {@link savePublicCollections} to update the database.- */-const savedPublicCollections = async (): Promise<Collection[]> =>- LocalCollections.parse(- (await localForage.getItem("public-collections")) ?? [],- );--/**- * Replace the list of public collections stored in our local database.- *- * This is the setter corresponding to {@link savedPublicCollections}.- */-const savePublicCollections = (collections: Collection[]) =>- localForage.setItem("public-collections", collections);--/**- * Return the saved public collection with the given {@link key} if present in- * our local database.- *- * Use {@link savePublicCollection} to save collections in our local database.- *- * @param key The collection key that can be used to identify the public album- * we want from amongst all the locally saved public albums.- */-export const savedPublicCollectionByKey = async (- collectionKey: string,-): Promise<Collection | undefined> =>- savedPublicCollections().then((cs) =>- cs.find((c) => c.key == collectionKey),- );--/**- * Save a public collection to our local database.- *- * The collection can later be retrieved using {@link savedPublicCollection}.- * The collection can be removed using {@link removePublicCollection}.- */-export const savePublicCollection = async (collection: Collection) => {- const collections = await savedPublicCollections();- await savePublicCollections([- collection,- ...collections.filter((c) => c.id != collection.id),- ]);-};--/**- * Remove a public collection, identified using its collection key, from our- * local database.- *- * @param key The collection key that can be used to identify the public album- * we want to remove.- */-export const removePublicCollectionByKey = async (collectionKey: string) => {- const collections = await savedPublicCollections();- await savePublicCollections([- ...collections.filter((c) => c.key != collectionKey),- ]);-};--/**- * Zod schema for a nullish string, with `null` transformed to `undefined`.- */-const LocalString = z.string().nullish().transform(nullToUndefined);--/**- * Return the last saved referral code present in our local database.- *- * See: [Note: Public albums referral code]. A few more details specific to the- * persistence of the referral code:- *- * 1. The public albums app persists only the referral code for the latest- * public album that was fetched.- *- * 2. This saved value can be read by- * {@link savedLastPublicCollectionReferralCode}.- *- * 3. It gets updated as part of {@link publicAlbumsRemotePull}, which writes- * out a new value using {@link saveLastPublicCollectionReferralCode}.- */-export const savedLastPublicCollectionReferralCode = async () =>- LocalString.parse(await localForage.getItem("public-referral-code"));--/**- * Update the referral code present in our local database.- *- * This is the setter corresponding to- * {@link savedLastPublicCollectionReferralCode}.- */-export const saveLastPublicCollectionReferralCode = async (- referralCode: string,-) => {- await localForage.setItem("public-referral-code", referralCode);-};--const LocalSavedPublicCollectionFilesEntry = z.object({- /**- * The collection, identified by its access token.- *- * See: [Note: Public album access token]- */- collectionUID: z.string(),- files: LocalEnteFiles,-});--type LocalSavedPublicCollectionFilesEntry = z.infer<- typeof LocalSavedPublicCollectionFilesEntry->;--/**- * Return all files for a public collection present in our local database.- *- * Use {@link savePublicCollectionFiles} to update the list of files in the- * database, and {@link removePublicCollectionFiles} to remove them.- *- * @param accessToken The access token that identifies the public album whose- * files we want.- */-export const savedPublicCollectionFiles = async (- accessToken: string,-): Promise<EnteFile[]> => {- const entry = (await pcfEntries()).find(- (e) => e.collectionUID == accessToken,- );- return transformFilesIfNeeded(entry ? entry.files : []);-};--/**- * A convenience routine to read the DB entries for "public-collection-files".- */-const pcfEntries = async () => {- // A local alias to avoid the code from looking scary.- type ES = LocalSavedPublicCollectionFilesEntry[];-- // See: [Note: Avoiding Zod parsing for large DB arrays] for why we use an- // (implied) cast here instead of parsing using the Zod schema.- const entries = await localForage.getItem<ES>("public-collection-files");- return entries ?? [];-};--/**- * Replace the list of files for a public collection in our local database.- *- * This is the setter corresponding to {@link savedPublicCollectionFiles}.- *- * @param accessToken The access token that identifies the public album whose- * files we want to update.- *- * @param files The files to save.- */-export const savePublicCollectionFiles = async (- accessToken: string,- files: EnteFile[],-): Promise<void> => {- await localForage.setItem("public-collection-files", [- { collectionUID: accessToken, files },- ...(await pcfEntries()).filter((e) => e.collectionUID != accessToken),- ]);-};--/**- * Remove the list of files, in any, in our local database for the given- * collection (identified by its {@link accessToken}).- */-export const removePublicCollectionFiles = async (- accessToken: string,-): Promise<void> => {- await localForage.setItem("public-collection-files", [- ...(await pcfEntries()).filter((e) => e.collectionUID != accessToken),- ]);-};--/**- * Return the locally persisted "last sync time" for a public collection that we- * have pulled from remote. This can be used to perform a paginated delta pull- * from the saved time onwards.- *- * Use {@link savePublic CollectionLastSyncTime} to update the value saved in- * the database, and {@link removePublicCollectionLastSyncTime} to remove the- * saved value from the database.- *- * @param accessToken The access token that identifies the public album whose- * last sync time we want.- */-export const savedPublicCollectionLastSyncTime = async (accessToken: string) =>- LocalTimestamp.parse(- await localForage.getItem(`public-${accessToken}-time`),- );--/**- * Update the locally persisted timestamp that will be returned by subsequent- * calls to {@link savedPublicCollectionLastSyncTime}.- */-export const savePublicCollectionLastSyncTime = async (- accessToken: string,- time: number,-) => {- await localForage.setItem(`public-${accessToken}-time`, time);-};--/**- * Remove the locally persisted timestamp, if any, previously saved for a- * collection using {@link savedPublicCollectionLastSyncTime}.- */-export const removePublicCollectionLastSyncTime = async (- accessToken: string,-) => {- await localForage.removeItem(`public-${accessToken}-time`);-};--/**- * Return the access token JWT, if any, present in our local database for the- * given public collection (as identified by its {@link accessToken}).- *- * Use {@link savePublicCollectionAccessTokenJWT} to save the value, and- * {@link removePublicCollectionAccessTokenJWT} to remove it.- */-export const savedPublicCollectionAccessTokenJWT = async (- accessToken: string,-) =>- LocalString.parse(- await localForage.getItem(`public-${accessToken}-passkey`),- );--/**- * Update the access token JWT in our local database for the given public- * collection (as identified by its {@link accessToken}).- *- * This is the setter corresponding to- * {@link savedPublicCollectionAccessTokenJWT}.- */-export const savePublicCollectionAccessTokenJWT = async (- accessToken: string,- passwordJWT: string,-) => {- await localForage.setItem(`public-${accessToken}-passkey`, passwordJWT);-};--/**- * Remove the access token JWT in our local database for the given public- * collection (as identified by its {@link accessToken}).- */-export const removePublicCollectionAccessTokenJWT = async (- accessToken: string,-) => {- await localForage.removeItem(`public-${accessToken}-passkey`);-};--/**- * Return the previously saved uploader name, if any, present in our local- * database corresponding to a public collection.- *- * Use {@link savePublicCollectionUploaderName} to update the persisted value.- *- * [Note: Public albums uploader name]- *- * Whenever there is an upload to a public album, we ask the person doing the- * upload for their name. This uploader name is attached as part of the public- * magic metadata of the file so that other people know who uploaded the file.- *- * The public albums app also saves this value, keyed by an identifier for the- * public collection, in the local database so that it can prefill it the next- * time there is an upload from the same client.- *- * @param accessToken The access token that identifies the public album whose- * saved uploader name we want.- */-export const savedPublicCollectionUploaderName = async (accessToken: string) =>- LocalString.parse(- await localForage.getItem(`public-${accessToken}-uploaderName`),- );--/**- * Update the uploader name present in our local database corresponding to a- * public collection.- *- * This is the setter corresponding to- * {@link savedPublicCollectionUploaderName}.- */-export const savePublicCollectionUploaderName = async (- accessToken: string,- uploaderName: string,-) => {- await localForage.setItem(- `public-${accessToken}-uploaderName`,- uploaderName,- );-};diff --git a/web/packages/new/albums/services/public-collection.ts b/web/packages/new/albums/services/public-collection.tsdeleted file mode 100644index a6af813495..0000000000--- a/web/packages/new/albums/services/public-collection.ts+++ /dev/null@@ -1,265 +0,0 @@-import { deriveKey } from "ente-base/crypto";-import {- authenticatedPublicAlbumsRequestHeaders,- ensureOk,- type PublicAlbumsCredentials,-} from "ente-base/http";-import { apiURL } from "ente-base/origins";-import {- decryptRemoteCollection,- RemoteCollection,- type Collection,- type PublicURL,-} from "ente-media/collection";-import {- decryptRemoteFile,- FileDiffResponse,- type EnteFile,-} from "ente-media/file";-import { z } from "zod";-import {- removePublicCollectionAccessTokenJWT,- removePublicCollectionFiles,- removePublicCollectionLastSyncTime,- savedPublicCollectionFiles,- savedPublicCollectionLastSyncTime,- saveLastPublicCollectionReferralCode,- savePublicCollection,- savePublicCollectionFiles,- savePublicCollectionLastSyncTime,-} from "./public-albums-fdb";--/**- * Verify with remote that the password entered by the user is the same as the- * password that was set by the person who shared the public album.- *- * The verification is done on a password hash that we check with remote. If- * they match, remote will provide us with another token that can be used to- * make API calls for this password protected public album.- *- * If they don't match, or if {@link accessToken} itself has expired, then- * remote will return a HTTP 401.- *- * @param publicURL Data about the public album.- *- * @param password The password entered by the user.- *- * @param token The access token to make API requests for a particular public- * album.- *- * @returns A accessTokenJWT.- *- * See [Note: Password token for public albums requests]- */-export const verifyPublicAlbumPassword = async (- publicURL: PublicURL,- password: string,- accessToken: string,-) => {- const passwordHash = await deriveKey(- password,- // TODO: Fix the types to not require the bang.- publicURL.nonce!,- publicURL.opsLimit!,- publicURL.memLimit!,- );-- const res = await fetch(- await apiURL("/public-collection/verify-password"),- {- method: "POST",- headers: authenticatedPublicAlbumsRequestHeaders({ accessToken }),- body: JSON.stringify({ passHash: passwordHash }),- },- );- ensureOk(res);- return z.object({ jwtToken: z.string() }).parse(await res.json()).jwtToken;-};--/**- * Fetch a public collection from remote using its access key, decrypt it using- * the provided key, save the collection in our local database for subsequent- * use, and return it.- *- * This function modifies local state.- *- * @param accessToken A public collection access key obtained from the "t="- * query parameter of the public URL.- *- * The access key serves to both identify the public collection, and also- * authenticate the request. See: [Note: Public album access token].- *- * @param collectionKey The base64 encoded key that can be used to decrypt the- * collection obtained from remote.- *- * The collection key is obtained from the fragment portion of the public URL- * (the fragment is a client side only portion that can be used to have local- * secrets that are not sent by the browser to the server).- */-export const pullCollection = async (- accessToken: string,- collectionKey: string,-): Promise<{ collection: Collection; referralCode: string }> => {- const { collection: remoteCollection, referralCode } =- await getPublicCollectionInfo(accessToken);-- const collection = await decryptRemoteCollection(- remoteCollection,- collectionKey,- );-- await savePublicCollection(collection);- await saveLastPublicCollectionReferralCode(referralCode);-- return { collection, referralCode };-};--const PublicCollectionInfo = z.object({- collection: RemoteCollection,- /**- * A referral code of the owner of the public album.- *- * [Note: Public albums referral code]- *- * The information of a public collection contains the referral code of the- * person who shared the album. This allows both the viewer and the sharer- * to gain storage bonus.- */- referralCode: z.string(),-});--/**- * Fetch information from remote about a public collection using its access key.- *- * Remote only, does not modify local state.- *- * @param accessToken A public collection access key.- */-const getPublicCollectionInfo = async (accessToken: string) => {- const res = await fetch(await apiURL("/public-collection/info"), {- headers: authenticatedPublicAlbumsRequestHeaders({ accessToken }),- });- ensureOk(res);- return PublicCollectionInfo.parse(await res.json());-};--/**- * Pull any changes to the files belonging to the given collection, updating our- * local database and also calling the provided callback.- *- * This function modifies local state.- *- * The pull uses a persisted timestamp for the most recent change we've already- * fetched, and will be only fetch the delta of changes since the last pull. The- * files are fetched in a paginated manner, so the provided callback can get- * called multiple times during the pull (one for each page).- *- * @param credentials A public collection access key and an optional password- * unlocked access token JWT. The credentials serve to both identify the- * collection, and authenticate the request.- *- * @param collection The public collection corresponding to the credentials.- *- * This function assumes that collection has already been pulled from remote and- * is at its latest, remote, value. This assumption is used to skip fetching- * files if the collection has not changed on remote (any updates to the files- * will also increase the updation time of the collection that contains them).- *- * @param onSetFiles A callback that is invoked with the consolidated list of- * files after processing each batch of updates.- *- * The provided files are in an arbitrary order, and must be sorted before use.- *- * When called:- * - At least once if there are remote changes to fetch (may be called multiple- * times if changes span multiple pages)- * - Once with cached files if the diff is empty on first iteration (handles- * empty albums on initial load)- * - Not called if collection is already synced and no updates are needed- * (updationTime equals last sync time)- */-export const pullPublicCollectionFiles = async (- credentials: PublicAlbumsCredentials,- collection: Collection,- onSetFiles: (files: EnteFile[]) => void,-) => {- const { accessToken } = credentials;-- let sinceTime = (await savedPublicCollectionLastSyncTime(accessToken)) ?? 0;-- // Prior to reaching here, we would've already fetched the latest- // collection. If the updation time of the collection is the same as the- // last sync time, then we know there were no new updates (since updates to- // files also increase the updation time of their containing collection).- if (sinceTime == collection.updationTime) return;-- const files = await savedPublicCollectionFiles(accessToken);- const filesByID = new Map(files.map((f) => [f.id, f]));- let callbackInvoked = false;-- while (true) {- const { diff, hasMore } = await getPublicCollectionDiff(- credentials,- sinceTime,- );- if (!diff.length) {- // If the diff is empty on the first iteration, ensure we still- // notify the caller with the cached state (e.g., empty albums)- if (!callbackInvoked) {- onSetFiles(files);- }- break;- }- for (const change of diff) {- sinceTime = Math.max(sinceTime, change.updationTime);- if (change.isDeleted) {- filesByID.delete(change.id);- } else {- filesByID.set(- change.id,- await decryptRemoteFile(change, collection.key),- );- }- }-- const updatedFiles = [...filesByID.values()];- await savePublicCollectionFiles(accessToken, updatedFiles);- await savePublicCollectionLastSyncTime(accessToken, sinceTime);- onSetFiles(updatedFiles);- callbackInvoked = true;-- if (!hasMore) break;- }-};--/**- * Fetch the public collection diff to obtain updates to the collection- * (identified by its {@link credentials}) since {@link sinceTime}.- *- * Remote only, does not modify local state.- */-const getPublicCollectionDiff = async (- credentials: PublicAlbumsCredentials,- sinceTime: number,-) => {- const res = await fetch(- await apiURL("/public-collection/diff", { sinceTime }),- { headers: authenticatedPublicAlbumsRequestHeaders(credentials) },- );- ensureOk(res);- return FileDiffResponse.parse(await res.json());-};--/**- * Remove the files, sync time and accessTokenJWT associated with the given- * collection (identified by its {@link accessToken}).- *- * This function modifies local state.- */-export const removePublicCollectionFileData = async (accessToken: string) => {- await Promise.all([- removePublicCollectionAccessTokenJWT(accessToken),- removePublicCollectionLastSyncTime(accessToken),- removePublicCollectionFiles(accessToken),- ]);-};diff --git a/web/packages/new/albums/services/public-comment.ts b/web/packages/new/albums/services/public-comment.tsdeleted file mode 100644index 8fbbfde51b..0000000000--- a/web/packages/new/albums/services/public-comment.ts+++ /dev/null@@ -1,203 +0,0 @@-import { decryptBox, encryptBox } from "ente-base/crypto";-import {- authenticatedPublicAlbumsRequestHeaders,- ensureOk,- type PublicAlbumsCredentials,-} from "ente-base/http";-import { apiURL } from "ente-base/origins";-import { z } from "zod";-import { type AnonIdentity, getStoredAnonIdentity } from "./public-reaction";--/**- * A decrypted public comment.- */-export interface PublicComment {- id: string;- collectionID: number;- fileID?: number;- parentCommentID?: string;- userID: number;- anonUserID?: string;- /** The decrypted comment text. */- text: string;- isDeleted: boolean;- createdAt: number;- updatedAt: number;-}--/**- * Add a comment to a file in a public album (as an anonymous user).- *- * @param credentials Public album credentials (access token).- * @param collectionID The collection ID for looking up stored identity.- * @param fileID The ID of the file to comment on.- * @param text The comment text.- * @param collectionKey The decrypted collection key (base64 encoded).- * @param parentCommentID Optional parent comment ID for replies.- * @param anonIdentity Optional anonymous identity. If not provided, will use stored identity.- * @returns The ID of the created comment.- */-export const addPublicComment = async (- credentials: PublicAlbumsCredentials,- collectionID: number,- fileID: number,- text: string,- collectionKey: string,- parentCommentID?: string,- anonIdentity?: AnonIdentity,-): Promise<string> => {- const identity = anonIdentity ?? getStoredAnonIdentity(collectionID);- if (!identity) {- throw new Error("No anonymous identity available");- }-- const { encryptedData: cipher, nonce } = await encryptBox(- new TextEncoder().encode(text),- collectionKey,- );-- const res = await fetch(await apiURL("/public-collection/comments"), {- method: "POST",- headers: {- ...authenticatedPublicAlbumsRequestHeaders(credentials),- "Content-Type": "application/json",- },- body: JSON.stringify({- fileID,- cipher,- nonce,- parentCommentID,- anonUserID: identity.anonUserID,- anonToken: identity.token,- }),- });- ensureOk(res);- const { id } = CreateCommentResponse.parse(await res.json());- return id;-};--/**- * Delete a comment from a public album (as an anonymous user).- *- * @param credentials Public album credentials (access token).- * @param collectionID The collection ID for looking up stored identity.- * @param commentID The ID of the comment to delete.- * @param anonIdentity Optional anonymous identity. If not provided, will use stored identity.- */-export const deletePublicComment = async (- credentials: PublicAlbumsCredentials,- collectionID: number,- commentID: string,- anonIdentity?: AnonIdentity,-): Promise<void> => {- const identity = anonIdentity ?? getStoredAnonIdentity(collectionID);- if (!identity) {- throw new Error("No anonymous identity available");- }-- const res = await fetch(- await apiURL(`/public-collection/comments/${commentID}`),- {- method: "DELETE",- headers: {- ...authenticatedPublicAlbumsRequestHeaders(credentials),- "Content-Type": "application/json",- },- body: JSON.stringify({- anonUserID: identity.anonUserID,- anonToken: identity.token,- }),- },- );- ensureOk(res);-};--/**- * Get comments for a file in a public album.- *- * @param credentials Public album credentials (access token).- * @param fileID The ID of the file to get comments for.- * @param collectionKey The decrypted collection key (base64 encoded).- * @returns Array of decrypted comments for the file.- */-export const getPublicFileComments = async (- credentials: PublicAlbumsCredentials,- fileID: number,- collectionKey: string,-): Promise<PublicComment[]> => {- const res = await fetch(- await apiURL("/public-collection/comments/diff", {- fileID,- sinceTime: 0,- limit: 1000,- }),- { headers: authenticatedPublicAlbumsRequestHeaders(credentials) },- );- ensureOk(res);- const { comments } = GetPublicCommentsResponse.parse(await res.json());-- const decryptedComments: PublicComment[] = [];- for (const comment of comments) {- // Include deleted comments with empty text- if (comment.isDeleted || !comment.cipher || !comment.nonce) {- decryptedComments.push({- id: comment.id,- collectionID: comment.collectionID,- fileID: comment.fileID ?? undefined,- parentCommentID: comment.parentCommentID ?? undefined,- userID: comment.userID,- anonUserID: comment.anonUserID ?? undefined,- text: "",- isDeleted: comment.isDeleted,- createdAt: comment.createdAt,- updatedAt: comment.updatedAt,- });- continue;- }- try {- const decryptedB64 = await decryptBox(- { encryptedData: comment.cipher, nonce: comment.nonce },- collectionKey,- );- const text = new TextDecoder().decode(- Uint8Array.from(atob(decryptedB64), (c) => c.charCodeAt(0)),- );- decryptedComments.push({- id: comment.id,- collectionID: comment.collectionID,- fileID: comment.fileID ?? undefined,- parentCommentID: comment.parentCommentID ?? undefined,- userID: comment.userID,- anonUserID: comment.anonUserID ?? undefined,- text,- isDeleted: comment.isDeleted,- createdAt: comment.createdAt,- updatedAt: comment.updatedAt,- });- } catch {- // Skip comments that fail to decrypt- }- }- return decryptedComments;-};--const CreateCommentResponse = z.object({ id: z.string() });--const RemotePublicComment = z.object({- id: z.string(),- collectionID: z.number(),- fileID: z.number().nullish(),- parentCommentID: z.string().nullish(),- userID: z.number(),- anonUserID: z.string().nullish(),- cipher: z.string().nullish(),- nonce: z.string().nullish(),- isDeleted: z.boolean(),- createdAt: z.number(),- updatedAt: z.number(),-});--const GetPublicCommentsResponse = z.object({- comments: z.array(RemotePublicComment),- hasMore: z.boolean(),-});diff --git a/web/packages/new/albums/services/public-reaction.ts b/web/packages/new/albums/services/public-reaction.tsdeleted file mode 100644index 3eaffec009..0000000000--- a/web/packages/new/albums/services/public-reaction.ts+++ /dev/null@@ -1,781 +0,0 @@-import { decryptBox, encryptBox } from "ente-base/crypto";-import {- authenticatedPublicAlbumsRequestHeaders,- ensureOk,- type PublicAlbumsCredentials,-} from "ente-base/http";-import { apiURL } from "ente-base/origins";-import { z } from "zod";--/**- * Fixed length for padded reaction types.- * All reactions are padded to this length before encryption to prevent- * length-based analysis of the ciphertext.- * Max emoji name is ~70 chars, so 100 provides a safe buffer.- */-const paddedReactionLength = 100;--/**- * Pad a reaction type to a fixed length using null bytes.- */-const padReaction = (reactionType: string): string =>- reactionType.padEnd(paddedReactionLength, "\0");--/**- * Remove null byte padding from a decrypted reaction type.- */-const unpadReaction = (paddedReaction: string): string =>- paddedReaction.replace(/\0+$/, "");--/**- * Anonymous user identity returned when creating an anon identity.- */-export interface AnonIdentity {- anonUserID: string;- token: string;- expiresAt: number;-}--/**- * Storage key prefix for anonymous identity in local storage.- * The full key is `${prefix}_${collectionID}`.- */-const ANON_IDENTITY_STORAGE_KEY_PREFIX = "ente_anon_identity";--/**- * Get the storage key for a specific collection's anonymous identity.- */-const getStorageKey = (collectionID: number): string =>- `${ANON_IDENTITY_STORAGE_KEY_PREFIX}_${collectionID}`;--/**- * Get the stored anonymous identity for a specific collection from local storage.- *- * Returns undefined if no identity is stored or if the stored identity has expired.- * Expired identities are automatically cleared from storage.- *- * @param collectionID The collection ID to get the identity for.- */-export const getStoredAnonIdentity = (- collectionID: number,-): AnonIdentity | undefined => {- if (typeof window === "undefined") return undefined;- const stored = localStorage.getItem(getStorageKey(collectionID));- if (!stored) return undefined;- try {- const identity = JSON.parse(stored) as AnonIdentity;- // Check if the identity has expired.- // Server returns expiresAt in microseconds, Date.now() returns milliseconds.- const nowMicroseconds = Date.now() * 1000;- if (identity.expiresAt && nowMicroseconds > identity.expiresAt) {- // Clear expired identity so user can create a fresh one- clearAnonIdentity(collectionID);- return undefined;- }- return identity;- } catch {- return undefined;- }-};--/**- * Store the anonymous identity for a specific collection in local storage.- *- * @param collectionID The collection ID to store the identity for.- * @param identity The anonymous identity to store.- */-export const storeAnonIdentity = (- collectionID: number,- identity: AnonIdentity,-): void => {- if (typeof window === "undefined") return;- localStorage.setItem(getStorageKey(collectionID), JSON.stringify(identity));-};--/**- * Clear the stored anonymous identity for a specific collection from local storage.- *- * @param collectionID The collection ID to clear the identity for.- */-export const clearAnonIdentity = (collectionID: number): void => {- if (typeof window === "undefined") return;- localStorage.removeItem(getStorageKey(collectionID));-};--/**- * Create an anonymous identity for a public album.- *- * The server will return a unique anonymous user ID and a token that can be- * used to authenticate future requests (reactions, comments) from this- * anonymous user.- *- * @param credentials Public album credentials (access token).- * @param collectionID The collection ID this identity is for.- * @param userName The name entered by the user.- * @param collectionKey The decrypted collection key (base64 encoded).- * @returns The anonymous identity containing anonUserID and token.- */-export const createAnonIdentity = async (- credentials: PublicAlbumsCredentials,- collectionID: number,- userName: string,- collectionKey: string,-): Promise<AnonIdentity> => {- // Encrypt the user name using the collection key- const { encryptedData: cipher, nonce } = await encryptBox(- new TextEncoder().encode(userName),- collectionKey,- );-- const res = await fetch(await apiURL("/public-collection/anon-identity"), {- method: "POST",- headers: {- ...authenticatedPublicAlbumsRequestHeaders(credentials),- "Content-Type": "application/json",- },- body: JSON.stringify({ cipher, nonce }),- });- ensureOk(res);- const identity = AnonIdentityResponse.parse(await res.json());-- // Store the identity for this collection- storeAnonIdentity(collectionID, identity);-- return identity;-};--const AnonIdentityResponse = z.object({- anonUserID: z.string(),- token: z.string(),- expiresAt: z.number(),-});--/**- * Add a reaction to a file in a public album (as an anonymous user).- *- * @param credentials Public album credentials (access token).- * @param collectionID The collection ID for looking up stored identity.- * @param fileID The ID of the file to react to.- * @param reactionType The type of reaction (e.g., "green_heart").- * @param collectionKey The decrypted collection key (base64 encoded).- * @param anonIdentity Optional anonymous identity. If not provided, will use stored identity.- * @returns The ID of the created reaction.- */-export const addPublicReaction = async (- credentials: PublicAlbumsCredentials,- collectionID: number,- fileID: number,- reactionType: string,- collectionKey: string,- anonIdentity?: AnonIdentity,-): Promise<string> => {- const identity = anonIdentity ?? getStoredAnonIdentity(collectionID);- if (!identity) {- throw new Error("No anonymous identity available");- }-- const { encryptedData: cipher, nonce } = await encryptBox(- new TextEncoder().encode(padReaction(reactionType)),- collectionKey,- );-- const res = await fetch(await apiURL("/public-collection/reactions"), {- method: "POST",- headers: {- ...authenticatedPublicAlbumsRequestHeaders(credentials),- "Content-Type": "application/json",- },- body: JSON.stringify({- fileID,- cipher,- nonce,- anonUserID: identity.anonUserID,- anonToken: identity.token,- }),- });- ensureOk(res);- const { id } = UpsertReactionResponse.parse(await res.json());- return id;-};--/**- * Add a reaction to a comment in a public album (as an anonymous user).- *- * @param credentials Public album credentials (access token).- * @param collectionID The collection ID for looking up stored identity.- * @param commentID The ID of the comment to react to.- * @param reactionType The type of reaction (e.g., "green_heart").- * @param collectionKey The decrypted collection key (base64 encoded).- * @param anonIdentity Optional anonymous identity. If not provided, will use stored identity.- * @param fileID Optional file ID, required for file-scoped comments.- * @returns The ID of the created reaction.- */-export const addPublicCommentReaction = async (- credentials: PublicAlbumsCredentials,- collectionID: number,- commentID: string,- reactionType: string,- collectionKey: string,- anonIdentity?: AnonIdentity,- fileID?: number,-): Promise<string> => {- const identity = anonIdentity ?? getStoredAnonIdentity(collectionID);- if (!identity) {- throw new Error("No anonymous identity available");- }-- const { encryptedData: cipher, nonce } = await encryptBox(- new TextEncoder().encode(padReaction(reactionType)),- collectionKey,- );-- const res = await fetch(await apiURL("/public-collection/reactions"), {- method: "POST",- headers: {- ...authenticatedPublicAlbumsRequestHeaders(credentials),- "Content-Type": "application/json",- },- body: JSON.stringify({- commentID,- fileID,- cipher,- nonce,- anonUserID: identity.anonUserID,- anonToken: identity.token,- }),- });- ensureOk(res);- const { id } = UpsertReactionResponse.parse(await res.json());- return id;-};--/**- * Delete a reaction from a public album (as an anonymous user).- *- * @param credentials Public album credentials (access token).- * @param collectionID The collection ID for looking up stored identity.- * @param reactionID The ID of the reaction to delete.- * @param anonIdentity Optional anonymous identity. If not provided, will use stored identity.- */-export const deletePublicReaction = async (- credentials: PublicAlbumsCredentials,- collectionID: number,- reactionID: string,- anonIdentity?: AnonIdentity,-): Promise<void> => {- const identity = anonIdentity ?? getStoredAnonIdentity(collectionID);- if (!identity) {- throw new Error("No anonymous identity available");- }-- const res = await fetch(- await apiURL(`/public-collection/reactions/${reactionID}`),- {- method: "DELETE",- headers: {- ...authenticatedPublicAlbumsRequestHeaders(credentials),- "Content-Type": "application/json",- },- body: JSON.stringify({- anonUserID: identity.anonUserID,- anonToken: identity.token,- }),- },- );- ensureOk(res);-};--const UpsertReactionResponse = z.object({ id: z.string() });--/**- * A decrypted public reaction.- */-export interface PublicReaction {- id: string;- fileID: number;- commentID?: string;- reactionType: string;- userID: number;- anonUserID?: string;- isDeleted: boolean;- createdAt: number;- updatedAt: number;-}--/**- * Get reactions for a file in a public album.- *- * @param credentials Public album credentials (access token).- * @param fileID The ID of the file to get reactions for.- * @param collectionKey The decrypted collection key (base64 encoded).- * @returns Array of decrypted reactions for the file.- */-export const getPublicFileReactions = async (- credentials: PublicAlbumsCredentials,- fileID: number,- collectionKey: string,-): Promise<PublicReaction[]> => {- const res = await fetch(- await apiURL("/public-collection/reactions/diff", {- fileID,- sinceTime: 0,- limit: 100,- }),- { headers: authenticatedPublicAlbumsRequestHeaders(credentials) },- );- ensureOk(res);- const { reactions } = GetPublicReactionsResponse.parse(await res.json());-- const decryptedReactions: PublicReaction[] = [];- for (const reaction of reactions) {- // Skip deleted reactions (they have null cipher/nonce)- if (reaction.isDeleted || !reaction.cipher || !reaction.nonce) continue;- try {- const decryptedB64 = await decryptBox(- { encryptedData: reaction.cipher, nonce: reaction.nonce },- collectionKey,- );- const reactionType = unpadReaction(- new TextDecoder().decode(- Uint8Array.from(atob(decryptedB64), (c) => c.charCodeAt(0)),- ),- );- decryptedReactions.push({- id: reaction.id,- fileID: reaction.fileID ?? fileID,- commentID: reaction.commentID ?? undefined,- reactionType,- userID: reaction.userID,- anonUserID: reaction.anonUserID ?? undefined,- isDeleted: reaction.isDeleted,- createdAt: reaction.createdAt,- updatedAt: reaction.updatedAt,- });- } catch {- // Skip reactions that fail to decrypt- }- }- return decryptedReactions;-};--const RemotePublicReaction = z.object({- id: z.string(),- collectionID: z.number(),- fileID: z.number().nullish(),- commentID: z.string().nullish(),- userID: z.number(),- anonUserID: z.string().nullish(),- cipher: z.string().nullish(),- nonce: z.string().nullish(),- isDeleted: z.boolean(),- createdAt: z.number(),- updatedAt: z.number(),-});--const GetPublicReactionsResponse = z.object({- reactions: z.array(RemotePublicReaction),- hasMore: z.boolean(),-});--/**- * An anonymous user profile (encrypted).- */-export interface AnonProfile {- anonUserID: string;- userName: string;-}--/**- * Get anonymous user profiles for a public album.- *- * @param credentials Public album credentials (access token).- * @param collectionKey The decrypted collection key (base64 encoded).- * @returns Map of anonUserID to decrypted userName.- */-export const getPublicAnonProfiles = async (- credentials: PublicAlbumsCredentials,- collectionKey: string,-): Promise<Map<string, string>> => {- const res = await fetch(await apiURL("/public-collection/anon-profiles"), {- headers: authenticatedPublicAlbumsRequestHeaders(credentials),- });- ensureOk(res);- const { profiles } = GetAnonProfilesResponse.parse(await res.json());-- const anonUserNames = new Map<string, string>();- for (const profile of profiles) {- if (!profile.cipher || !profile.nonce) continue;- try {- const decryptedB64 = await decryptBox(- { encryptedData: profile.cipher, nonce: profile.nonce },- collectionKey,- );- const userName = new TextDecoder().decode(- Uint8Array.from(atob(decryptedB64), (c) => c.charCodeAt(0)),- );- if (userName) {- anonUserNames.set(profile.anonUserID, userName);- }- } catch {- // Skip profiles that fail to decrypt- }- }- return anonUserNames;-};--const RemoteAnonProfile = z.object({- anonUserID: z.string(),- collectionID: z.number(),- cipher: z.string().nullish(),- nonce: z.string().nullish(),- createdAt: z.number(),- updatedAt: z.number(),-});--const GetAnonProfilesResponse = z.object({- profiles: z- .array(RemoteAnonProfile)- .nullish()- .transform((v) => v ?? []),-});--/**- * A participant with masked email.- */-export interface Participant {- userID: number;- emailMasked: string;-}--/**- * Get registered participants' masked emails for a public album.- *- * This returns masked emails for registered users (album owner/collaborators)- * who have interacted with the album (comments/reactions).- *- * @param credentials Public album credentials (access token).- * @returns Map of userID to masked email.- */-export const getPublicParticipantsMaskedEmails = async (- credentials: PublicAlbumsCredentials,-): Promise<Map<number, string>> => {- const res = await fetch(- await apiURL("/public-collection/participants/masked-emails"),- { headers: authenticatedPublicAlbumsRequestHeaders(credentials) },- );- ensureOk(res);- const { participants } = GetParticipantsResponse.parse(await res.json());-- const userIDToEmail = new Map<number, string>();- for (const participant of participants) {- userIDToEmail.set(participant.userID, participant.emailMasked);- }- return userIDToEmail;-};--const RemoteParticipant = z.object({- userID: z.number(),- emailMasked: z.string(),-});--const GetParticipantsResponse = z.object({- participants: z.array(RemoteParticipant),-});--// =============================================================================-// Unified Social Diff-// =============================================================================--/**- * A decrypted public comment.- */-export interface PublicComment {- id: string;- collectionID: number;- fileID?: number;- parentCommentID?: string;- userID: number;- anonUserID?: string;- text: string;- isDeleted: boolean;- createdAt: number;- updatedAt: number;-}--/**- * Result of fetching unified social diff.- */-export interface PublicSocialDiff {- comments: PublicComment[];- reactions: PublicReaction[];-}--/**- * Get both comments and reactions for a file in a public album in a single API call.- *- * @param credentials Public album credentials (access token).- * @param fileID The ID of the file to get social data for.- * @param collectionKey The decrypted collection key (base64 encoded).- * @returns Object containing both decrypted comments and reactions.- */-export const getPublicSocialDiff = async (- credentials: PublicAlbumsCredentials,- fileID: number,- collectionKey: string,-): Promise<PublicSocialDiff> => {- const res = await fetch(- await apiURL("/public-collection/social/diff", {- fileID,- sinceTime: 0,- limit: 1000,- }),- { headers: authenticatedPublicAlbumsRequestHeaders(credentials) },- );- ensureOk(res);- const data = GetPublicSocialDiffResponse.parse(await res.json());-- // Decrypt comments- const comments: PublicComment[] = [];- for (const comment of data.comments) {- // Include deleted comments with empty text- if (comment.isDeleted || !comment.cipher || !comment.nonce) {- comments.push({- id: comment.id,- collectionID: comment.collectionID,- fileID: comment.fileID ?? undefined,- parentCommentID: comment.parentCommentID ?? undefined,- userID: comment.userID,- anonUserID: comment.anonUserID ?? undefined,- text: "",- isDeleted: comment.isDeleted,- createdAt: comment.createdAt,- updatedAt: comment.updatedAt,- });- continue;- }- try {- const decryptedB64 = await decryptBox(- { encryptedData: comment.cipher, nonce: comment.nonce },- collectionKey,- );- const text = new TextDecoder().decode(- Uint8Array.from(atob(decryptedB64), (c) => c.charCodeAt(0)),- );- comments.push({- id: comment.id,- collectionID: comment.collectionID,- fileID: comment.fileID ?? undefined,- parentCommentID: comment.parentCommentID ?? undefined,- userID: comment.userID,- anonUserID: comment.anonUserID ?? undefined,- text,- isDeleted: comment.isDeleted,- createdAt: comment.createdAt,- updatedAt: comment.updatedAt,- });- } catch {- // Skip comments that fail to decrypt- }- }-- // Decrypt reactions- const reactions: PublicReaction[] = [];- for (const reaction of data.reactions) {- // Skip deleted reactions (they have null cipher/nonce)- if (reaction.isDeleted || !reaction.cipher || !reaction.nonce) continue;- try {- const decryptedB64 = await decryptBox(- { encryptedData: reaction.cipher, nonce: reaction.nonce },- collectionKey,- );- const reactionType = unpadReaction(- new TextDecoder().decode(- Uint8Array.from(atob(decryptedB64), (c) => c.charCodeAt(0)),- ),- );- reactions.push({- id: reaction.id,- fileID: reaction.fileID ?? fileID,- commentID: reaction.commentID ?? undefined,- reactionType,- userID: reaction.userID,- anonUserID: reaction.anonUserID ?? undefined,- isDeleted: reaction.isDeleted,- createdAt: reaction.createdAt,- updatedAt: reaction.updatedAt,- });- } catch {- // Skip reactions that fail to decrypt- }- }-- return { comments, reactions };-};--const RemotePublicComment = z.object({- id: z.string(),- collectionID: z.number(),- fileID: z.number().nullish(),- parentCommentID: z.string().nullish(),- userID: z.number(),- anonUserID: z.string().nullish(),- cipher: z.string().nullish(),- nonce: z.string().nullish(),- isDeleted: z.boolean(),- createdAt: z.number(),- updatedAt: z.number(),-});--const GetPublicSocialDiffResponse = z.object({- comments: z.array(RemotePublicComment),- reactions: z.array(RemotePublicReaction),- hasMoreComments: z.boolean(),- hasMoreReactions: z.boolean(),-});--// =============================================================================-// Public Album Feed-// =============================================================================--/**- * A public comment extended with isReply flag for feed processing.- */-export interface PublicFeedComment extends PublicComment {- /** True if this comment is a reply to another comment. */- isReply: boolean;-}--/**- * A public reaction extended with isCommentReply flag for feed processing.- */-export interface PublicFeedReaction extends PublicReaction {- /** True if this reaction is on a reply (comment with parent). */- isCommentReply?: boolean;-}--/**- * Result of fetching all social data for a public album feed.- */-export interface PublicAlbumFeed {- comments: PublicFeedComment[];- reactions: PublicFeedReaction[];-}--/**- * Get all comments and reactions for a public album (for the feed).- *- * Unlike getPublicSocialDiff which is per-file, this fetches ALL social data- * for the entire album without filtering by file.- *- * @param credentials Public album credentials (access token).- * @param collectionKey The decrypted collection key (base64 encoded).- * @returns Object containing all decrypted comments and reactions for the album.- */-export const getPublicAlbumFeed = async (- credentials: PublicAlbumsCredentials,- collectionKey: string,-): Promise<PublicAlbumFeed> => {- // Fetch all social data without fileID filter- const res = await fetch(- await apiURL("/public-collection/social/diff", {- sinceTime: 0,- limit: 1000,- }),- { headers: authenticatedPublicAlbumsRequestHeaders(credentials) },- );- ensureOk(res);- const data = GetPublicSocialDiffResponse.parse(await res.json());-- // Build a map of comment IDs to their parent status for determining isCommentReply- const commentParentMap = new Map<string, boolean>();-- // Decrypt comments- const comments: PublicFeedComment[] = [];- for (const comment of data.comments) {- const isReply = !!comment.parentCommentID;- commentParentMap.set(comment.id, isReply);-- // Include deleted comments with empty text- if (comment.isDeleted || !comment.cipher || !comment.nonce) {- comments.push({- id: comment.id,- collectionID: comment.collectionID,- fileID: comment.fileID ?? undefined,- parentCommentID: comment.parentCommentID ?? undefined,- userID: comment.userID,- anonUserID: comment.anonUserID ?? undefined,- text: "",- isDeleted: comment.isDeleted,- createdAt: comment.createdAt,- updatedAt: comment.updatedAt,- isReply,- });- continue;- }- try {- const decryptedB64 = await decryptBox(- { encryptedData: comment.cipher, nonce: comment.nonce },- collectionKey,- );- const text = new TextDecoder().decode(- Uint8Array.from(atob(decryptedB64), (c) => c.charCodeAt(0)),- );- comments.push({- id: comment.id,- collectionID: comment.collectionID,- fileID: comment.fileID ?? undefined,- parentCommentID: comment.parentCommentID ?? undefined,- userID: comment.userID,- anonUserID: comment.anonUserID ?? undefined,- text,- isDeleted: comment.isDeleted,- createdAt: comment.createdAt,- updatedAt: comment.updatedAt,- isReply,- });- } catch {- // Skip comments that fail to decrypt- }- }-- // Decrypt reactions- const reactions: PublicFeedReaction[] = [];- for (const reaction of data.reactions) {- // Skip deleted reactions (they have null cipher/nonce)- if (reaction.isDeleted || !reaction.cipher || !reaction.nonce) continue;- try {- const decryptedB64 = await decryptBox(- { encryptedData: reaction.cipher, nonce: reaction.nonce },- collectionKey,- );- const reactionType = unpadReaction(- new TextDecoder().decode(- Uint8Array.from(atob(decryptedB64), (c) => c.charCodeAt(0)),- ),- );-- // Determine if this reaction is on a reply by checking the comment's parent status- let isCommentReply: boolean | undefined;- if (reaction.commentID) {- isCommentReply = commentParentMap.get(reaction.commentID);- }-- reactions.push({- id: reaction.id,- fileID: reaction.fileID ?? 0,- commentID: reaction.commentID ?? undefined,- isCommentReply,- reactionType,- userID: reaction.userID,- anonUserID: reaction.anonUserID ?? undefined,- isDeleted: reaction.isDeleted,- createdAt: reaction.createdAt,- updatedAt: reaction.updatedAt,- });- } catch {- // Skip reactions that fail to decrypt- }- }-- return { comments, reactions };-};