π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
alt
Manav Rathi6676668c8621
diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsxindex 3cfb0679b8..25e6d254fe 100644--- a/web/packages/gallery/components/viewer/FileViewer.tsx+++ b/web/packages/gallery/components/viewer/FileViewer.tsx@@ -26,7 +26,6 @@ import {type FileInfoProps,} from "@/gallery/components/FileInfo";import type { Collection } from "@/media/collection";-import { fileCaption } from "@/media/file-metadata";import { FileType } from "@/media/file-type";import type { EnteFile } from "@/media/file.js";import { isHEICExtension, needsJPEGConversion } from "@/media/formats";@@ -284,6 +283,7 @@ const FileViewer: React.FC<FileViewerProps> = ({const handleAnnotate = useCallback((file: EnteFile): FileViewerFileAnnotation => {log.debug(() => ["viewer", { action: "annotate", file }]);+const fileID = file.id;const isOwnFile = file.ownerID == user?.id;const canModify =@@ -293,14 +293,12 @@ const FileViewer: React.FC<FileViewerProps> = ({handleEditImage && canModify? fileIsEditableImage(file): undefined;- const caption = fileCaption(file);return {fileID,isOwnFile,showFavorite,isEditableImage,- caption,};},[user, isInTrashSection, isInHiddenSection, handleEditImage],diff --git a/web/packages/gallery/components/viewer/data-source.ts b/web/packages/gallery/components/viewer/data-source.tsindex 7b931d488b..5c6d4ef7f5 100644--- a/web/packages/gallery/components/viewer/data-source.ts+++ b/web/packages/gallery/components/viewer/data-source.ts@@ -6,6 +6,7 @@ import {} from "@/gallery/services/download";import { extractRawExif, parseExif } from "@/gallery/services/exif";import type { EnteFile } from "@/media/file";+import { fileCaption } from "@/media/file-metadata";import { FileType } from "@/media/file-type";import { ensureString } from "@/utils/ensure";@@ -97,6 +98,15 @@ export type ItemData = PhotoSwipeSlideData & {* It is set while the thumbnail is loaded.*/isContentZoomable?: boolean;+ /**+ * The alt text associated with the file.+ *+ * This will be set to the file's caption. PhotoSwipe will use it as the alt+ * text when constructing img elements (if any) for this item. We will also+ * use this for displaying the visible "caption" element atop the file (both+ * images and video).+ */+ alt?: string;/*** This will be `true` if the fetch for the file's data has failed.*@@ -244,7 +254,11 @@ const enqueueUpdates = async (file: EnteFile) => {const fileType = file.metadata.fileType;const update = (itemData: Partial<ItemData>) => {- _state.itemDataByFileID.set(file.id, { ...itemData, fileType, fileID });+ // Use the file's caption as its alt text (in addition to using it as+ // the visible caption).+ const alt = fileCaption(file);++ _state.itemDataByFileID.set(file.id, { ...itemData, fileType, fileID, alt });_state.needsRefreshByFileID.get(file.id)?.();};diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.tsindex 7e2415a684..73c60bf916 100644--- a/web/packages/gallery/components/viewer/photoswipe.ts+++ b/web/packages/gallery/components/viewer/photoswipe.ts@@ -345,8 +345,8 @@ export class FileViewerPhotoSwipe {pswp.refreshSlideContent(index),);- const { fileType, videoURL, ...rest } = itemData;- if (fileType === FileType.video && videoURL) {+ const { videoURL, ...rest } = itemData;+ if (itemData.fileType === FileType.video && videoURL) {const disableDownload = !!this.opts.disableDownload;itemData = {...rest,@@ -631,19 +631,16 @@ export class FileViewerPhotoSwipe {tagName: "p",onInit: (captionElement, pswp) =>pswp.on("change", () => {- const { file, annotation } = currentAnnotatedFile();- const caption = annotation.caption ?? "";- captionElement.innerText = caption;- captionElement.style.visibility = caption+ const { fileType, alt } = pswp.currSlide.content.data;+ captionElement.innerText = alt ?? "";+ captionElement.style.visibility = alt? "visible": "hidden";// Add extra offset for video captions so that they do// not overlap with the video controls. The constant is// an ad-hoc value that looked okay-ish across browsers.captionElement.style.bottom =- file.metadata.fileType === FileType.video- ? "36px"- : "0";+ fileType === FileType.video ? "36px" : "0";}),});});