π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Fix comments sidebar for public albums and add anon identity expiry check
Anand Baburajan9232af093217
diff --git a/web/apps/photos/src/components/TripLayout/index.tsx b/web/apps/photos/src/components/TripLayout/index.tsxindex 4cfee47b75..d894829f87 100644--- a/web/apps/photos/src/components/TripLayout/index.tsx+++ b/web/apps/photos/src/components/TripLayout/index.tsx@@ -594,6 +594,7 @@ export const TripLayout: React.FC<TripLayoutProps> = ({publicAlbumsCredentials={credentials?.current}collectionKey={collectionKey}onJoinAlbum={handleJoinAlbum}+ enableComment={enableComment}/>{/* Download progress notifications */}diff --git a/web/packages/gallery/components/viewer/CommentsSidebar.tsx b/web/packages/gallery/components/viewer/CommentsSidebar.tsxindex c8c6a2387e..a6bc87f8c3 100644--- a/web/packages/gallery/components/viewer/CommentsSidebar.tsx+++ b/web/packages/gallery/components/viewer/CommentsSidebar.tsx@@ -641,9 +641,14 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({};}, [open, highlightCommentID, loading, comments]);- // Reset selected collection when the file changes (gallery view only)+ // Reset state when the file changes to avoid showing stale datauseEffect(() => {setSelectedCollectionID(undefined);+ setComments([]);+ setCommentsByCollection(new Map());+ setReactionsByCollection(new Map());+ setLikedComments(new Map());+ hasLoadedRef.current = false;}, [file?.id]);// Check if opened from a collection context@@ -802,17 +807,20 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({// 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 collectionSummarieslet maxCount = -1;let bestCollectionID: number | undefined;for (const [collectionID,collectionComments,] of prefetchedComments) {- // Skip non-shared collections- const isShared = collectionSummaries- ?.get(collectionID)- ?.attributes.has("shared");- if (!isShared) continue;+ // Skip non-shared collections (except for public albums)+ if (!isPublicAlbum) {+ const isShared = collectionSummaries+ ?.get(collectionID)+ ?.attributes.has("shared");+ if (!isShared) continue;+ }const count = collectionComments.filter((c) => !c.isDeleted,@@ -846,6 +854,7 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({hasCollectionContext,activeCollectionID,collectionSummaries,+ isPublicAlbum,]);// Load comments when the sidebar opens@@ -865,17 +874,20 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({) {// 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 collectionSummarieslet maxCount = -1;let bestCollectionID: number | undefined;for (const [collectionID,collectionComments,] of commentsByCollection) {- // Skip non-shared collections- const isShared = collectionSummaries- ?.get(collectionID)- ?.attributes.has("shared");- if (!isShared) continue;+ // Skip non-shared collections (except for public albums)+ if (!isPublicAlbum) {+ const isShared = collectionSummaries+ ?.get(collectionID)+ ?.attributes.has("shared");+ if (!isShared) continue;+ }const count = collectionComments.filter((c) => !c.isDeleted,@@ -895,6 +907,7 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({selectedCollectionID,commentsByCollection,collectionSummaries,+ isPublicAlbum,]);// Update displayed comments when selected collection changes (gallery view)diff --git a/web/packages/new/albums/services/public-reaction.ts b/web/packages/new/albums/services/public-reaction.tsindex 3fd5c329b9..3eaffec009 100644--- a/web/packages/new/albums/services/public-reaction.ts+++ b/web/packages/new/albums/services/public-reaction.ts@@ -51,6 +51,9 @@ const getStorageKey = (collectionID: number): string =>/*** 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 = (@@ -60,7 +63,16 @@ export const getStoredAnonIdentity = (const stored = localStorage.getItem(getStorageKey(collectionID));if (!stored) return undefined;try {- return JSON.parse(stored) as AnonIdentity;+ 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;}