π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Surface public album errors
Anand Baburajan1e17ce183148
diff --git a/web/apps/albums/src/public-album/components/TripLayout/hooks/useDataProcessing.ts b/web/apps/albums/src/public-album/components/TripLayout/hooks/useDataProcessing.tsindex 5b1b9c420e..170a30ca47 100644--- a/web/apps/albums/src/public-album/components/TripLayout/hooks/useDataProcessing.ts+++ b/web/apps/albums/src/public-album/components/TripLayout/hooks/useDataProcessing.ts@@ -1,6 +1,7 @@+import { useBaseContext } from "ente-base/context";import type { Collection } from "ente-media/collection";import type { EnteFile } from "ente-media/file";-import { useEffect } from "react";+import { useEffect, useRef } from "react";import type { JourneyPoint } from "../types";import { loadCoverImage, processPhotosData } from "../utils/dataProcessing";@@ -34,6 +35,9 @@ export const useDataProcessing = ({setIsLoadingLocations,setCoverImageUrl,}: UseDataProcessingParams) => {+ const { onGenericError } = useBaseContext();+ const reportedCoverErrorFileIDRef = useRef<number | undefined>(undefined);+useEffect(() => {const hasFilesCountChanged = files.length !== filesCountRef.current;filesCountRef.current = files.length;@@ -44,10 +48,12 @@ export const useDataProcessing = ({thumbnailsGeneratedRef.current = false;- const { photoData, hasLocationData } = processPhotosData({- files,- locationDataRef,- });+ const { photoData, hasLocationData, processingError } =+ processPhotosData({ files, locationDataRef });++ if (processingError) {+ onGenericError(processingError);+ }setJourneyData(photoData);setIsInitialLoad(false);@@ -64,20 +70,35 @@ export const useDataProcessing = ({setJourneyData,setIsInitialLoad,setIsLoadingLocations,+ onGenericError,]);useEffect(() => {const loadCover = async () => {- const coverUrl = await loadCoverImage({+ const { coverImageURL, coverImageError } = await loadCoverImage({journeyData,files,collection,});- if (coverUrl) {- setCoverImageUrl(coverUrl);+ const coverFileID =+ collection?.pubMagicMetadata?.data.coverID ??+ journeyData[0]?.fileId;++ if (+ coverImageError &&+ reportedCoverErrorFileIDRef.current !== coverFileID+ ) {+ reportedCoverErrorFileIDRef.current = coverFileID;+ onGenericError(coverImageError);+ } else if (!coverImageError) {+ reportedCoverErrorFileIDRef.current = undefined;+ }++ if (coverImageURL) {+ setCoverImageUrl(coverImageURL);}};void loadCover();- }, [journeyData, files, collection, setCoverImageUrl]);+ }, [journeyData, files, collection, setCoverImageUrl, onGenericError]);};diff --git a/web/apps/albums/src/public-album/components/TripLayout/hooks/useThumbnailGeneration.ts b/web/apps/albums/src/public-album/components/TripLayout/hooks/useThumbnailGeneration.tsindex 3c1190aac2..292450f197 100644--- a/web/apps/albums/src/public-album/components/TripLayout/hooks/useThumbnailGeneration.ts+++ b/web/apps/albums/src/public-album/components/TripLayout/hooks/useThumbnailGeneration.ts@@ -1,3 +1,4 @@+import { useBaseContext } from "ente-base/context";import type { EnteFile } from "ente-media/file";import { useEffect, useRef } from "react";@@ -20,6 +21,7 @@ export const useThumbnailGeneration = ({thumbnailsGeneratedRef,setJourneyData,}: UseThumbnailGenerationParams) => {+ const { onGenericError } = useBaseContext();const processedPhotoIdsRef = useRef<Set<number>>(new Set());useEffect(() => {@@ -41,10 +43,8 @@ export const useThumbnailGeneration = ({if (photosNeedingThumbnails.length === 0) return;- const { thumbnailUpdates } = await generateNeededThumbnails({- photoClusters,- files,- });+ const { thumbnailUpdates, thumbnailError } =+ await generateNeededThumbnails({ photoClusters, files });if (thumbnailUpdates.size > 0) {setJourneyData((prevData) =>@@ -58,6 +58,10 @@ export const useThumbnailGeneration = ({);}+ if (thumbnailError) {+ onGenericError(thumbnailError);+ }+processedPhotoIdsRef.current = new Set([...processedPhotoIdsRef.current,...currentPhotoIds,@@ -66,5 +70,11 @@ export const useThumbnailGeneration = ({};void generateThumbs();- }, [photoClusters, files, thumbnailsGeneratedRef, setJourneyData]);+ }, [+ photoClusters,+ files,+ thumbnailsGeneratedRef,+ setJourneyData,+ onGenericError,+ ]);};diff --git a/web/apps/albums/src/public-album/components/TripLayout/utils/dataProcessing.ts b/web/apps/albums/src/public-album/components/TripLayout/utils/dataProcessing.tsindex 22624cff39..883841ca94 100644--- a/web/apps/albums/src/public-album/components/TripLayout/utils/dataProcessing.ts+++ b/web/apps/albums/src/public-album/components/TripLayout/utils/dataProcessing.ts@@ -20,6 +20,7 @@ export interface ProcessPhotosDataParams {export interface ProcessPhotosDataResult {photoData: JourneyPoint[];hasLocationData: boolean;+ processingError?: unknown;}export const processPhotosData = ({@@ -27,6 +28,7 @@ export const processPhotosData = ({locationDataRef,}: ProcessPhotosDataParams): ProcessPhotosDataResult => {const photoData: JourneyPoint[] = [];+ let processingError: unknown;if (files.length === 0) {return { photoData, hasLocationData: false };@@ -51,14 +53,18 @@ export const processPhotosData = ({fileId: file.id,});}- } catch {- // Silently ignore processing errors for individual files+ } catch (e) {+ processingError ??= e;}}photoData.sort((a, b) => a.timestamp - b.timestamp);- return { photoData, hasLocationData: photoData.length > 0 };+ return {+ photoData,+ hasLocationData: photoData.length > 0,+ processingError,+ };};export interface FetchLocationNamesParams {@@ -89,15 +95,11 @@ export const fetchLocationNames = async ({const representativePhoto = cluster[0];if (!representativePhoto) return null;- try {- const locationInfo = await getLocationName(- representativePhoto.lat,- representativePhoto.lng,- );- return { cluster, locationInfo };- } catch {- return null;- }+ const locationInfo = await getLocationName(+ representativePhoto.lat,+ representativePhoto.lng,+ );+ return { cluster, locationInfo };});const results = await Promise.all(geocodingPromises);@@ -128,6 +130,7 @@ export interface GenerateThumbnailsParams {export interface GenerateThumbnailsResult {thumbnailUpdates: Map<number, string>;+ thumbnailError?: unknown;}export const generateNeededThumbnails = async ({@@ -135,6 +138,7 @@ export const generateNeededThumbnails = async ({files,}: GenerateThumbnailsParams): Promise<GenerateThumbnailsResult> => {const thumbnailUpdates = new Map<number, string>();+ let thumbnailError: unknown;if (photoClusters.length === 0) {return { thumbnailUpdates };@@ -195,8 +199,8 @@ export const generateNeededThumbnails = async ({if (thumbnailUrl) {thumbnailUpdates.set(file.id, thumbnailUrl);}- } catch {- // Silently ignore thumbnail generation errors+ } catch (e) {+ thumbnailError ??= e;}});@@ -208,7 +212,7 @@ export const generateNeededThumbnails = async ({}}- return { thumbnailUpdates };+ return { thumbnailUpdates, thumbnailError };};export interface LoadCoverImageParams {@@ -217,12 +221,17 @@ export interface LoadCoverImageParams {collection?: { pubMagicMetadata?: { data: { coverID?: number } } };}+export interface LoadCoverImageResult {+ coverImageURL: string | null;+ coverImageError?: unknown;+}+export const loadCoverImage = async ({journeyData,files,collection,-}: LoadCoverImageParams): Promise<string | null> => {- if (journeyData.length === 0) return null;+}: LoadCoverImageParams): Promise<LoadCoverImageResult> => {+ if (journeyData.length === 0) return { coverImageURL: null };let coverFile: EnteFile | undefined;@@ -233,21 +242,21 @@ export const loadCoverImage = async ({if (!coverFile) {const firstPhoto = journeyData[0];- if (!firstPhoto) return null;+ if (!firstPhoto) return { coverImageURL: null };coverFile = files.find((f) => f.id === firstPhoto.fileId);}- if (!coverFile) return null;+ if (!coverFile) return { coverImageURL: null };try {const sourceURLs =await downloadManager.renderableSourceURLs(coverFile);if (sourceURLs.type === "image") {- return sourceURLs.imageURL;+ return { coverImageURL: sourceURLs.imageURL };}- } catch {- // Keep using thumbnail if high quality fails+ } catch (e) {+ return { coverImageURL: null, coverImageError: e };}- return null;+ return { coverImageURL: null };};diff --git a/web/apps/albums/src/public-album/social/api/public-comment.ts b/web/apps/albums/src/public-album/social/api/public-comment.tsindex ff5f1aaf2c..51ce4335a2 100644--- a/web/apps/albums/src/public-album/social/api/public-comment.ts+++ b/web/apps/albums/src/public-album/social/api/public-comment.ts@@ -1,4 +1,4 @@-import { decryptBox, encryptBox } from "ente-base/crypto";+import { encryptBox } from "ente-base/crypto";import {authenticatedPublicAlbumsRequestHeaders,ensureOk,@@ -8,19 +8,6 @@ import { apiURL } from "ente-base/origins";import { z } from "zod";import { type AnonIdentity, getStoredAnonIdentity } from "./public-reaction";-export interface PublicComment {- id: string;- collectionID: number;- fileID?: number;- parentCommentID?: string;- userID: number;- anonUserID?: string;- text: string;- isDeleted: boolean;- createdAt: number;- updatedAt: number;-}-export const addPublicComment = async (credentials: PublicAlbumsCredentials,collectionID: number,@@ -88,83 +75,4 @@ export const deletePublicComment = async (ensureOk(res);};-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) {- 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/apps/albums/src/public-album/social/api/public-reaction.ts b/web/apps/albums/src/public-album/social/api/public-reaction.tsindex 289619bda1..55c7e9cd41 100644--- a/web/apps/albums/src/public-album/social/api/public-reaction.ts+++ b/web/apps/albums/src/public-album/social/api/public-reaction.ts@@ -212,53 +212,6 @@ export interface PublicReaction {updatedAt: number;}-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) {- 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(),@@ -273,20 +226,20 @@ const RemotePublicReaction = z.object({updatedAt: z.number(),});-const GetPublicReactionsResponse = z.object({- reactions: z.array(RemotePublicReaction),- hasMore: z.boolean(),-});-export interface AnonProfile {anonUserID: string;userName: string;}+export interface PublicAnonProfiles {+ anonUserNames: Map<string, string>;+ decryptionError: unknown;+}+export const getPublicAnonProfiles = async (credentials: PublicAlbumsCredentials,collectionKey: string,-): Promise<Map<string, string>> => {+): Promise<PublicAnonProfiles> => {const res = await fetch(await apiURL("/public-collection/anon-profiles"), {headers: authenticatedPublicAlbumsRequestHeaders(credentials),});@@ -294,6 +247,7 @@ export const getPublicAnonProfiles = async (const { profiles } = GetAnonProfilesResponse.parse(await res.json());const anonUserNames = new Map<string, string>();+ let decryptionError: unknown;for (const profile of profiles) {if (!profile.cipher || !profile.nonce) continue;try {@@ -307,11 +261,11 @@ export const getPublicAnonProfiles = async (if (userName) {anonUserNames.set(profile.anonUserID, userName);}- } catch {- // Skip profiles that fail to decrypt+ } catch (e) {+ decryptionError ??= e;}}- return anonUserNames;+ return { anonUserNames, decryptionError };};const RemoteAnonProfile = z.object({@@ -377,6 +331,7 @@ export interface PublicComment {export interface PublicSocialDiff {comments: PublicComment[];reactions: PublicReaction[];+ decryptionError: unknown;}export const getPublicSocialDiff = async (@@ -395,6 +350,7 @@ export const getPublicSocialDiff = async (ensureOk(res);const data = GetPublicSocialDiffResponse.parse(await res.json());+ let decryptionError: unknown;const comments: PublicComment[] = [];for (const comment of data.comments) {if (comment.isDeleted || !comment.cipher || !comment.nonce) {@@ -432,8 +388,8 @@ export const getPublicSocialDiff = async (createdAt: comment.createdAt,updatedAt: comment.updatedAt,});- } catch {- // Skip comments that fail to decrypt+ } catch (e) {+ decryptionError ??= e;}}@@ -461,12 +417,12 @@ export const getPublicSocialDiff = async (createdAt: reaction.createdAt,updatedAt: reaction.updatedAt,});- } catch {- // Skip reactions that fail to decrypt+ } catch (e) {+ decryptionError ??= e;}}- return { comments, reactions };+ return { comments, reactions, decryptionError };};const RemotePublicComment = z.object({@@ -501,6 +457,7 @@ export interface PublicFeedReaction extends PublicReaction {export interface PublicAlbumFeed {comments: PublicFeedComment[];reactions: PublicFeedReaction[];+ decryptionError: unknown;}export const getPublicAlbumFeed = async (@@ -517,6 +474,7 @@ export const getPublicAlbumFeed = async (ensureOk(res);const data = GetPublicSocialDiffResponse.parse(await res.json());+ let decryptionError: unknown;const commentParentMap = new Map<string, boolean>();const comments: PublicFeedComment[] = [];@@ -561,8 +519,8 @@ export const getPublicAlbumFeed = async (updatedAt: comment.updatedAt,isReply,});- } catch {- // Skip comments that fail to decrypt+ } catch (e) {+ decryptionError ??= e;}}@@ -597,10 +555,10 @@ export const getPublicAlbumFeed = async (createdAt: reaction.createdAt,updatedAt: reaction.updatedAt,});- } catch {- // Skip reactions that fail to decrypt+ } catch (e) {+ decryptionError ??= e;}}- return { comments, reactions };+ return { comments, reactions, decryptionError };};diff --git a/web/apps/albums/src/public-album/upload/components/UploaderNameInput.tsx b/web/apps/albums/src/public-album/upload/components/UploaderNameInput.tsxindex 4f301a0e77..df5cf3006c 100644--- a/web/apps/albums/src/public-album/upload/components/UploaderNameInput.tsx+++ b/web/apps/albums/src/public-album/upload/components/UploaderNameInput.tsx@@ -136,7 +136,7 @@ export const UploaderNameInputForm: React.FC<await onSubmit(value);onClose();} catch (e) {- log.error(`Failed to submit input ${value}`, e);+ log.error("Failed to submit uploader name", e);setValueFieldError(t("generic_error"));}},diff --git a/web/apps/albums/src/public-album/viewer/components/FileViewer.tsx b/web/apps/albums/src/public-album/viewer/components/FileViewer.tsxindex caaf3e38c9..f757fdf5b9 100644--- a/web/apps/albums/src/public-album/viewer/components/FileViewer.tsx+++ b/web/apps/albums/src/public-album/viewer/components/FileViewer.tsx@@ -172,6 +172,30 @@ export const FileViewer: React.FC<FileViewerProps> = ({);const [publicSocialDataStatusByFileID, setPublicSocialDataStatusByFileID] =useState<Map<number, "loading" | "ready">>(new Map());+ const publicSocialDataErrorReportedRef = useRef(false);+ const anonProfilesErrorReportedRef = useRef(false);++ const reportPublicSocialDataError = useCallback(+ (e: unknown) => {+ if (publicSocialDataErrorReportedRef.current) return;+ publicSocialDataErrorReportedRef.current = true;+ onGenericError(e);+ },+ [onGenericError],+ );++ const reportAnonProfilesError = useCallback(+ (e: unknown) => {+ if (anonProfilesErrorReportedRef.current) return;+ anonProfilesErrorReportedRef.current = true;+ onGenericError(e);+ },+ [onGenericError],+ );++ useEffect(() => {+ anonProfilesErrorReportedRef.current = false;+ }, [collectionKey]);useEffect(() => {if (!initialAnonUserNames?.size) return;@@ -846,6 +870,8 @@ export const FileViewer: React.FC<FileViewerProps> = ({const file = files.find((f) => f.id === activeFileID);if (!file) return;+ publicSocialDataErrorReportedRef.current = false;+setPublicSocialDataStatusByFileID((prev) => {if (prev.get(activeFileID) === "ready") return prev;@@ -856,11 +882,17 @@ export const FileViewer: React.FC<FileViewerProps> = ({void (async () => {try {- const { comments, reactions } = await getPublicSocialDiff(- publicAlbumsCredentials,- activeFileID,- collectionKey,- );+ const { comments, reactions, decryptionError } =+ await getPublicSocialDiff(+ publicAlbumsCredentials,+ activeFileID,+ collectionKey,+ );+ if (decryptionError) {+ reportPublicSocialDataError(decryptionError);+ } else {+ publicSocialDataErrorReportedRef.current = false;+ }const commentsForFile: Comment[] = comments.map((c) => ({id: c.id,@@ -909,10 +941,16 @@ export const FileViewer: React.FC<FileViewerProps> = ({});try {- const anonProfiles = await getPublicAnonProfiles(- publicAlbumsCredentials,- collectionKey,- );+ const { anonUserNames: anonProfiles, decryptionError } =+ await getPublicAnonProfiles(+ publicAlbumsCredentials,+ collectionKey,+ );+ if (decryptionError) {+ reportAnonProfilesError(decryptionError);+ } else {+ anonProfilesErrorReportedRef.current = false;+ }setAnonUserNames((prev) => {const next = new Map(prev);for (const [id, name] of anonProfiles) {@@ -920,8 +958,8 @@ export const FileViewer: React.FC<FileViewerProps> = ({}return next;});- } catch {- // Names are optional enrichment.+ } catch (e) {+ reportAnonProfilesError(e);}try {@@ -940,7 +978,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({// Names are optional enrichment.}} catch (e) {- log.error("Failed to fetch public social data", e);+ reportPublicSocialDataError(e);} finally {setPublicSocialDataStatusByFileID((prev) => {if (prev.get(activeFileID) === "ready") return prev;@@ -958,6 +996,8 @@ export const FileViewer: React.FC<FileViewerProps> = ({publicAlbumsCredentials,collectionKey,files,+ reportAnonProfilesError,+ reportPublicSocialDataError,]);useEffect(() => {@@ -981,11 +1021,17 @@ export const FileViewer: React.FC<FileViewerProps> = ({if (!file) return;try {- const { comments, reactions } = await getPublicSocialDiff(- publicAlbumsCredentials,- activeFileID,- collectionKey,- );+ const { comments, reactions, decryptionError } =+ await getPublicSocialDiff(+ publicAlbumsCredentials,+ activeFileID,+ collectionKey,+ );+ if (decryptionError) {+ reportPublicSocialDataError(decryptionError);+ } else {+ publicSocialDataErrorReportedRef.current = false;+ }const commentsForFile: Comment[] = comments.map((c) => ({id: c.id,@@ -1032,10 +1078,16 @@ export const FileViewer: React.FC<FileViewerProps> = ({});try {- const anonProfiles = await getPublicAnonProfiles(- publicAlbumsCredentials,- collectionKey,- );+ const { anonUserNames: anonProfiles, decryptionError } =+ await getPublicAnonProfiles(+ publicAlbumsCredentials,+ collectionKey,+ );+ if (decryptionError) {+ reportAnonProfilesError(decryptionError);+ } else {+ anonProfilesErrorReportedRef.current = false;+ }setAnonUserNames((prev) => {const next = new Map(prev);for (const [id, name] of anonProfiles) {@@ -1043,12 +1095,12 @@ export const FileViewer: React.FC<FileViewerProps> = ({}return next;});- } catch {- // Names are optional enrichment.+ } catch (e) {+ reportAnonProfilesError(e);}// Masked participant emails are stable enough to fetch only on open.} catch (e) {- log.error("Failed to refresh public social data", e);+ reportPublicSocialDataError(e);}}, [activeFileID,@@ -1056,6 +1108,8 @@ export const FileViewer: React.FC<FileViewerProps> = ({collectionKey,enableComment,files,+ reportAnonProfilesError,+ reportPublicSocialDataError,]);useInterval(diff --git a/web/apps/albums/src/public-album/viewer/components/PublicFeedSidebar.tsx b/web/apps/albums/src/public-album/viewer/components/PublicFeedSidebar.tsxindex 5b0e4d0248..1f7ff19151 100644--- a/web/apps/albums/src/public-album/viewer/components/PublicFeedSidebar.tsx+++ b/web/apps/albums/src/public-album/viewer/components/PublicFeedSidebar.tsx@@ -21,6 +21,7 @@ import {import { useColorScheme } from "@mui/material/styles";import { useInterval } from "ente-base/components/utils/hooks";import type { ModalVisibilityProps } from "ente-base/components/utils/modal";+import { useBaseContext } from "ente-base/context";import type { PublicAlbumsCredentials } from "ente-base/http";import log from "ente-base/log";import { getAvatarColor } from "ente-gallery/utils/avatar-colors";@@ -529,6 +530,7 @@ export const PublicFeedSidebar: React.FC<PublicFeedSidebarProps> = ({onItemClick,onExited,}) => {+ const { onGenericError } = useBaseContext();const { clearBrowserBackState } = useBrowserBackClose({open,onClose,@@ -550,6 +552,7 @@ export const PublicFeedSidebar: React.FC<PublicFeedSidebarProps> = ({new Map(),);const [isLoading, setIsLoading] = useState(false);+ const errorReportedRef = useRef(false);const thumbnailCacheRef = useRef(thumbnailCache);const thumbnailLoadsInFlightRef = useRef<Set<number>>(new Set());const canSetThumbnailCacheRef = useRef(open);@@ -562,6 +565,15 @@ export const PublicFeedSidebar: React.FC<PublicFeedSidebarProps> = ({canSetThumbnailCacheRef.current = open;}, [open]);+ const reportError = useCallback(+ (e: unknown) => {+ if (errorReportedRef.current) return;+ errorReportedRef.current = true;+ onGenericError(e);+ },+ [onGenericError],+ );+useEffect(() => () => {canSetThumbnailCacheRef.current = false;@@ -645,14 +657,22 @@ export const PublicFeedSidebar: React.FC<PublicFeedSidebarProps> = ({]);setComments(feedData.comments);setReactions(feedData.reactions);- setAnonUserNames(anonProfiles);+ setAnonUserNames(anonProfiles.anonUserNames);+ const decryptionError =+ feedData.decryptionError ?? anonProfiles.decryptionError;+ if (decryptionError) {+ reportError(decryptionError);+ } else {+ errorReportedRef.current = false;+ }} catch (e) {- log.error("Failed to refresh public album feed", e);+ reportError(e);}- }, [credentials, collectionKey]);+ }, [credentials, collectionKey, reportError]);useEffect(() => {if (!open) return;+ errorReportedRef.current = false;const fetchInitialData = async () => {try {@@ -664,16 +684,23 @@ export const PublicFeedSidebar: React.FC<PublicFeedSidebarProps> = ({]);setComments(feedData.comments);setReactions(feedData.reactions);- setAnonUserNames(anonProfiles);+ setAnonUserNames(anonProfiles.anonUserNames);setMaskedEmails(participantEmails);+ const decryptionError =+ feedData.decryptionError ?? anonProfiles.decryptionError;+ if (decryptionError) {+ reportError(decryptionError);+ } else {+ errorReportedRef.current = false;+ }} catch (e) {- log.error("Failed to fetch public album feed", e);+ reportError(e);}};setIsLoading(true);void fetchInitialData().finally(() => setIsLoading(false));- }, [open, credentials, collectionKey]);+ }, [open, credentials, collectionKey, reportError]);useInterval(refreshSocialData,