π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Preserve anon names from public feed
Anand Baburajan7f6388323213
diff --git a/web/apps/albums/src/public-album/components/FileListWithViewer.tsx b/web/apps/albums/src/public-album/components/FileListWithViewer.tsxindex a622cb29bd..e3b74f2f4f 100644--- a/web/apps/albums/src/public-album/components/FileListWithViewer.tsx+++ b/web/apps/albums/src/public-album/components/FileListWithViewer.tsx@@ -40,6 +40,10 @@ export type FileListWithViewerProps = {* The comment ID to highlight when navigating from feed.*/pendingHighlightCommentID?: string;+ /**+ * Resolved anonymous display names from the feed for the target album.+ */+ pendingAnonUserNames?: Map<string, string>;/*** Called after the pending navigation is consumed.*/@@ -87,6 +91,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({pendingFileIndex,pendingFileSidebar,pendingHighlightCommentID,+ pendingAnonUserNames,onPendingNavigationConsumed,publicAlbumsCredentials,collectionKey,@@ -102,6 +107,9 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({const [highlightCommentID, setHighlightCommentID] = useState<string | undefined>(undefined);+ const [initialAnonUserNames, setInitialAnonUserNames] = useState<+ Map<string, string> | undefined+ >(undefined);// Handle pending navigation from feed item clicksuseEffect(() => {@@ -109,6 +117,11 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({setCurrentIndex(pendingFileIndex);setInitialSidebar(pendingFileSidebar);setHighlightCommentID(pendingHighlightCommentID);+ setInitialAnonUserNames(+ pendingAnonUserNames+ ? new Map(pendingAnonUserNames)+ : undefined,+ );setOpenFileViewer(true);onPendingNavigationConsumed?.();}@@ -116,6 +129,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({pendingFileIndex,pendingFileSidebar,pendingHighlightCommentID,+ pendingAnonUserNames,onPendingNavigationConsumed,]);@@ -123,6 +137,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({const handleCloseFileViewerInternal = useCallback(() => {setInitialSidebar(undefined);setHighlightCommentID(undefined);+ setInitialAnonUserNames(undefined);setOpenFileViewer(false);}, []);@@ -188,6 +203,7 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({initialIndex={currentIndex}initialSidebar={initialSidebar}highlightCommentID={highlightCommentID}+ initialAnonUserNames={initialAnonUserNames}disableDownload={!enableDownload}{...{files,diff --git a/web/apps/albums/src/public-album/components/TripLayout/index.tsx b/web/apps/albums/src/public-album/components/TripLayout/index.tsxindex f49f072f11..f48ede73fa 100644--- a/web/apps/albums/src/public-album/components/TripLayout/index.tsx+++ b/web/apps/albums/src/public-album/components/TripLayout/index.tsx@@ -92,6 +92,9 @@ export const TripLayout: React.FC<TripLayoutProps> = ({const [highlightCommentID, setHighlightCommentID] = useState<string | undefined>(undefined);+ const [initialAnonUserNames, setInitialAnonUserNames] = useState<+ Map<string, string> | undefined+ >(undefined);// File viewer hookconst {@@ -138,6 +141,9 @@ export const TripLayout: React.FC<TripLayoutProps> = ({// Set navigation state and open file viewersetInitialSidebar(sidebar);setHighlightCommentID(info.commentID);+ setInitialAnonUserNames(+ info.anonUserNames ? new Map(info.anonUserNames) : undefined,+ );handleOpenFileViewer(cluster, info.fileID);};@@ -147,6 +153,7 @@ export const TripLayout: React.FC<TripLayoutProps> = ({const handleCloseFileViewerWithCleanup = () => {setInitialSidebar(undefined);setHighlightCommentID(undefined);+ setInitialAnonUserNames(undefined);handleCloseFileViewer();};@@ -590,6 +597,7 @@ export const TripLayout: React.FC<TripLayoutProps> = ({initialIndex={currentFileIndex}initialSidebar={initialSidebar}highlightCommentID={highlightCommentID}+ initialAnonUserNames={initialAnonUserNames}files={viewerFiles}disableDownload={!enableDownload}publicAlbumsCredentials={credentials?.current}diff --git a/web/apps/albums/src/public-album/page/PublicAlbumPage.tsx b/web/apps/albums/src/public-album/page/PublicAlbumPage.tsxindex 5cda12e76d..513d71b929 100644--- a/web/apps/albums/src/public-album/page/PublicAlbumPage.tsx+++ b/web/apps/albums/src/public-album/page/PublicAlbumPage.tsx@@ -173,6 +173,7 @@ export default function PublicAlbumPage() {fileIndex: number;sidebar?: FileViewerInitialSidebar;commentID?: string;+ anonUserNames?: Map<string, string>;}>();/**@@ -199,6 +200,9 @@ export default function PublicAlbumPage() {fileIndex,sidebar,commentID: info.commentID,+ anonUserNames: info.anonUserNames+ ? new Map(info.anonUserNames)+ : undefined,});};@@ -759,6 +763,9 @@ export default function PublicAlbumPage() {pendingHighlightCommentID={pendingFileNavigation?.commentID}+ pendingAnonUserNames={+ pendingFileNavigation?.anonUserNames+ }onPendingNavigationConsumed={() =>setPendingFileNavigation(undefined)}diff --git a/web/apps/albums/src/public-album/viewer/components/FileViewer.tsx b/web/apps/albums/src/public-album/viewer/components/FileViewer.tsxindex ebb2fe249e..5580e2aac0 100644--- a/web/apps/albums/src/public-album/viewer/components/FileViewer.tsx+++ b/web/apps/albums/src/public-album/viewer/components/FileViewer.tsx@@ -93,6 +93,7 @@ export type FileViewerProps = ModalVisibilityProps & {initialIndex: number;initialSidebar?: FileViewerInitialSidebar;highlightCommentID?: string;+ initialAnonUserNames?: Map<string, string>;disableDownload?: boolean;showFullscreenButton?: boolean;onDownload?: (file: EnteFile) => void;@@ -116,6 +117,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({initialIndex,initialSidebar,highlightCommentID,+ initialAnonUserNames,disableDownload,showFullscreenButton,onDownload,@@ -204,9 +206,27 @@ export const FileViewer: React.FC<FileViewerProps> = ({// Map of anon user ID to decrypted user name for anonymous users.const [anonUserNames, setAnonUserNames] = useState<Map<string, string>>(- new Map(),+ () =>+ initialAnonUserNames ? new Map(initialAnonUserNames) : new Map(),);+ useEffect(() => {+ if (!initialAnonUserNames?.size) return;++ setAnonUserNames((prev) => {+ let didChange = false;+ const next = new Map(prev);++ for (const [anonUserID, userName] of initialAnonUserNames) {+ if (next.get(anonUserID) === userName) continue;+ next.set(anonUserID, userName);+ didChange = true;+ }++ return didChange ? next : prev;+ });+ }, [initialAnonUserNames]);+// Ref for allReactions to use in callbacksconst allReactionsRef = useRef(allReactions);useEffect(() => {diff --git a/web/apps/albums/src/public-album/viewer/components/PublicFeedSidebar.tsx b/web/apps/albums/src/public-album/viewer/components/PublicFeedSidebar.tsxindex 56d30feffe..a0287e7637 100644--- a/web/apps/albums/src/public-album/viewer/components/PublicFeedSidebar.tsx+++ b/web/apps/albums/src/public-album/viewer/components/PublicFeedSidebar.tsx@@ -145,6 +145,12 @@ export interface PublicFeedItemClickInfo {* For `liked_comment`, this is the target comment ID.*/commentID?: string;+ /**+ * Snapshot of resolved anonymous display names from the feed.+ * This lets the viewer open with stable names instead of briefly falling+ * back to anonymous placeholders before its own profile fetch completes.+ */+ anonUserNames?: Map<string, string>;}export interface PublicFeedSidebarProps extends ModalVisibilityProps {@@ -589,26 +595,32 @@ const FeedItemRow: React.FC<FeedItemRowProps> = ({ item, onClick }) => {*/const getFeedItemClickInfo = (item: PublicFeedItem,+ anonUserNames: Map<string, string>,): PublicFeedItemClickInfo => {+ const clickInfoBase = { anonUserNames: new Map(anonUserNames) };+switch (item.type) {case "liked_photo":case "liked_video":- return { type: item.type, fileID: item.fileID };+ return { ...clickInfoBase, type: item.type, fileID: item.fileID };case "commented_photo":case "commented_video":return {+ ...clickInfoBase,type: item.type,fileID: item.fileID,commentID: item.commentID,};case "replied_comment":return {+ ...clickInfoBase,type: item.type,fileID: item.fileID!,commentID: item.replyID,};case "liked_comment":return {+ ...clickInfoBase,type: item.type,fileID: item.fileID!,commentID: item.commentID,@@ -825,7 +837,10 @@ export const PublicFeedSidebar: React.FC<PublicFeedSidebarProps> = ({onItemClick? () => {onItemClick(- getFeedItemClickInfo(item),+ getFeedItemClickInfo(+ item,+ anonUserNames,+ ),);}: undefined