π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
update(web):added-album-desc
Aswin Asok89becef0a70e
diff --git a/desktop/changes/album-description-rendering.md b/desktop/changes/album-description-rendering.mdnew file mode 100644index 0000000000..37a1b009b8--- /dev/null+++ b/desktop/changes/album-description-rendering.md@@ -0,0 +1 @@+- Added album descriptions across the Photos app, public albums, embeds, and trip layouts.diff --git a/desktop/changes/edit-album-details.md b/desktop/changes/edit-album-details.mdnew file mode 100644index 0000000000..1769eeffc4--- /dev/null+++ b/desktop/changes/edit-album-details.md@@ -0,0 +1 @@+- Added a unified album details dialog for editing album names, descriptions, and cover photos.diff --git a/web/apps/albums/src/public-album/components/FileList.tsx b/web/apps/albums/src/public-album/components/FileList.tsxindex a7eb1cbfd8..c767c6bc07 100644--- a/web/apps/albums/src/public-album/components/FileList.tsx+++ b/web/apps/albums/src/public-album/components/FileList.tsx@@ -30,6 +30,7 @@ import React, {useCallback,useDeferredValue,useEffect,+ useLayoutEffect,useMemo,useRef,useState,@@ -271,9 +272,9 @@ export const FileList: React.FC<FileListProps> = ({emptyStateAction,]);- useEffect(() => {+ useLayoutEffect(() => {listRef.current?.resetAfterIndex(0);- }, [items]);+ }, [items, header?.height]);useEffect(() => {const notSelectedFiles = annotatedFiles.filter(@@ -483,8 +484,11 @@ export const FileList: React.FC<FileListProps> = ({);const itemSize = useCallback(- (index: number) => itemData.items[index]!.height,- [itemData],+ (index: number) =>+ index == 0 && header && itemData.items[0]?.type == "span"+ ? header.height+ : itemData.items[index]!.height,+ [header, itemData],);const itemKey = useCallback((index: number, itemData: FileListItemData) => {diff --git a/web/apps/albums/src/public-album/components/TripLayout/MobileCover.tsx b/web/apps/albums/src/public-album/components/TripLayout/MobileCover.tsxindex f38ec12e4a..3107b52b85 100644--- a/web/apps/albums/src/public-album/components/TripLayout/MobileCover.tsx+++ b/web/apps/albums/src/public-album/components/TripLayout/MobileCover.tsx@@ -1,15 +1,17 @@import { Box, Skeleton, styled, Typography } from "@mui/material";+import { AlbumDescription } from "ente-new/photos/components/gallery/ListHeader";import { memo } from "react";import type { JourneyPoint } from "./types";interface MobileCoverProps {journeyData: JourneyPoint[];albumTitle?: string;+ albumDescription?: string;coverImageUrl?: string | null;}export const MobileCover = memo<MobileCoverProps>(- ({ journeyData, albumTitle, coverImageUrl }) => {+ ({ journeyData, albumTitle, albumDescription, coverImageUrl }) => {const sortedData = [...journeyData].sort((a, b) => a.timestamp - b.timestamp,);@@ -64,10 +66,22 @@ export const MobileCover = memo<MobileCoverProps>({coverImageUrl ? (<><TripTitle>{albumTitle || "Trip"}</TripTitle>- <TripSubtitle>+ <TripSubtitle+ sx={{ pb: albumDescription ? 0 : undefined }}+ >{monthYear} β’ {diffDays} days β’ {locationCount}{" "}locations</TripSubtitle>+ <AlbumDescription+ key={albumDescription}+ description={albumDescription}+ expandable+ sx={{+ mt: "4px",+ pb: "20px",+ color: "rgba(255, 255, 255, 0.85)",+ }}+ /></>) : (<>diff --git a/web/apps/albums/src/public-album/components/TripLayout/TripCover.tsx b/web/apps/albums/src/public-album/components/TripLayout/TripCover.tsxindex 8b21cfb8d2..f045200d6e 100644--- a/web/apps/albums/src/public-album/components/TripLayout/TripCover.tsx+++ b/web/apps/albums/src/public-album/components/TripLayout/TripCover.tsx@@ -1,16 +1,18 @@import { Box, Skeleton, styled, Typography } from "@mui/material";import { EnteLogo } from "ente-base/components/EnteLogo";+import { AlbumDescription } from "ente-new/photos/components/gallery/ListHeader";import { memo } from "react";import type { JourneyPoint } from "./types";interface TripCoverProps {journeyData: JourneyPoint[];albumTitle?: string;+ albumDescription?: string;coverImageUrl?: string | null;}export const TripCover = memo<TripCoverProps>(- ({ journeyData, albumTitle, coverImageUrl }) => {+ ({ journeyData, albumTitle, albumDescription, coverImageUrl }) => {const sortedData = [...journeyData].sort((a, b) => a.timestamp - b.timestamp,);@@ -74,6 +76,16 @@ export const TripCover = memo<TripCoverProps>({monthYear} β’ {diffDays} days β’{" "}{locationCount} locations</TripSubtitle>+ <AlbumDescription+ key={albumDescription}+ description={albumDescription}+ expandable+ sx={{+ maxWidth: "420px",+ mt: "4px",+ color: "rgba(255, 255, 255, 0.85)",+ }}+ /></>) : (<>diff --git a/web/apps/albums/src/public-album/components/TripLayout/index.tsx b/web/apps/albums/src/public-album/components/TripLayout/index.tsxindex 0f7d7d0b83..f5e4fbc483 100644--- a/web/apps/albums/src/public-album/components/TripLayout/index.tsx+++ b/web/apps/albums/src/public-album/components/TripLayout/index.tsx@@ -62,6 +62,7 @@ export const TripLayout: React.FC<TripLayoutProps> = ({enableJoin = false,}) => {const collectionTitle = collection?.name || albumTitle || "Trip";+ const albumDescription = collection?.pubMagicMetadata?.data.caption?.trim();const theme = useTheme();const isMobileOrTablet = useMediaQuery(theme.breakpoints.down("md"));@@ -365,6 +366,7 @@ export const TripLayout: React.FC<TripLayoutProps> = ({<MobileCoverjourneyData={journeyData}albumTitle={collectionTitle}+ albumDescription={albumDescription}coverImageUrl={coverImageUrl}/></MobileCoverOverlay>@@ -465,6 +467,7 @@ export const TripLayout: React.FC<TripLayoutProps> = ({<TripCoverjourneyData={journeyData}albumTitle={collectionTitle}+ albumDescription={albumDescription}coverImageUrl={coverImageUrl}/>diff --git a/web/apps/albums/src/public-album/page/PublicAlbumPage.tsx b/web/apps/albums/src/public-album/page/PublicAlbumPage.tsxindex 72ee653407..d3586d3a8c 100644--- a/web/apps/albums/src/public-album/page/PublicAlbumPage.tsx+++ b/web/apps/albums/src/public-album/page/PublicAlbumPage.tsx@@ -74,6 +74,8 @@ import type { EnteFile } from "ente-media/file";import { fileCreationTime, fileFileName } from "ente-media/file-metadata";import { FileType } from "ente-media/file-type";import {+ AlbumDescription,+ galleryItemsDescriptionHeight,GalleryItemsHeaderAdapter,GalleryItemsSummary,} from "ente-new/photos/components/gallery/ListHeader";@@ -598,11 +600,23 @@ export default function PublicAlbumPage() {const isMobileHeaderLayout = useMediaQuery("(width < 720px)");const showMobileMasonryCover =isMobileHeaderLayout && publicAlbumLayout === "masonry";- const fileListHeaderHeightForViewport = isMobileHeaderLayout- ? showMobileMasonryCover- ? mobileMasonryFileListHeaderHeight(viewportWidth)- : fileListHeaderHeightMobile- : fileListHeaderHeight;+ const albumDescription =+ publicCollection?.pubMagicMetadata?.data.caption?.trim();+ const hasSummaryDescription = !!albumDescription && !showMobileMasonryCover;+ const [descriptionHeight, setDescriptionHeight] = useState(0);++ useEffect(() => {+ setDescriptionHeight(+ hasSummaryDescription ? galleryItemsDescriptionHeight : 0,+ );+ }, [hasSummaryDescription, albumDescription]);++ const fileListHeaderHeightForViewport =+ (isMobileHeaderLayout+ ? showMobileMasonryCover+ ? mobileMasonryFileListHeaderHeight(viewportWidth)+ : fileListHeaderHeightMobile+ : fileListHeaderHeight) + descriptionHeight;const fileListHeader = useMemo<FileListHeaderOrFooter | undefined>(() =>@@ -623,6 +637,7 @@ export default function PublicAlbumPage() {hasSelection,showMobileMasonryCover,}}+ onDescriptionHeightChange={setDescriptionHeight}/>),height: fileListHeaderHeightForViewport,@@ -1110,6 +1125,7 @@ interface FileListHeaderProps {addPhotosDisabled: boolean;hasSelection: boolean;showMobileMasonryCover: boolean;+ onDescriptionHeightChange?: (height: number) => void;}const fileListHeaderHeight = 84;@@ -1126,8 +1142,11 @@ const FileListHeader: React.FC<FileListHeaderProps> = ({addPhotosDisabled,hasSelection,showMobileMasonryCover,+ onDescriptionHeightChange,}) => {const [showCopiedMessage, setShowCopiedMessage] = useState(false);+ const albumDescription =+ publicCollection.pubMagicMetadata?.data.caption?.trim();const memoriesDateRange = useMemo(() => {return quickLinkDateRangeForFiles(publicFiles);@@ -1214,6 +1233,7 @@ const FileListHeader: React.FC<FileListHeaderProps> = ({<PublicAlbumCoverHerocoverFile={coverFile}title={publicCollection.name}+ description={albumDescription}fileCount={publicFiles.length}dateRange={isQuickLinkAlbum ? undefined : memoriesDateRange@@ -1242,6 +1262,10 @@ const FileListHeader: React.FC<FileListHeaderProps> = ({><GalleryItemsSummaryname={publicCollection.name}+ description={albumDescription}+ onDescriptionHeightChange={+ onDescriptionHeightChange+ }fileCount={publicFiles.length}endIcon={!isQuickLinkAlbum && memoriesDateRange ? (@@ -1388,6 +1412,7 @@ const actionButtonSx = (variant: "default" | "cover") =>interface PublicAlbumCoverHeroProps {coverFile: EnteFile | undefined;title: string;+ description?: string;fileCount: number;dateRange?: string;actions?: React.ReactNode;@@ -1396,6 +1421,7 @@ interface PublicAlbumCoverHeroProps {const PublicAlbumCoverHero: React.FC<PublicAlbumCoverHeroProps> = ({coverFile,title,+ description,fileCount,dateRange,actions,@@ -1517,6 +1543,12 @@ const PublicAlbumCoverHero: React.FC<PublicAlbumCoverHeroProps> = ({<MobileMasonryCoverGradient $isPlaceholder={isPlaceholder} /><MobileMasonryCoverContent><MobileMasonryCoverTitle>{title}</MobileMasonryCoverTitle>+ <AlbumDescription+ key={description}+ description={description}+ expandable+ sx={{ maxWidth: "100%", mt: "-6px", opacity: 0.8 }}+ /><Typographyvariant="small"sx={{diff --git a/web/apps/embed/src/components/EmbedFileListWithViewer.tsx b/web/apps/embed/src/components/EmbedFileListWithViewer.tsxindex 83988425d9..78633cff92 100644--- a/web/apps/embed/src/components/EmbedFileListWithViewer.tsx+++ b/web/apps/embed/src/components/EmbedFileListWithViewer.tsx@@ -54,6 +54,9 @@ export const EmbedFileListWithViewer: React.FC<[onRemotePull],);+ const albumDescription =+ publicCollection.pubMagicMetadata?.data.caption?.trim();+const header = useMemo(() => (<GalleryItemsHeaderAdapter@@ -62,6 +65,7 @@ export const EmbedFileListWithViewer: React.FC<<SpacedRow><GalleryItemsSummaryname={publicCollection.name}+ description={albumDescription}fileCount={files.length}/><Typography@@ -95,7 +99,7 @@ export const EmbedFileListWithViewer: React.FC<</SpacedRow></GalleryItemsHeaderAdapter>),- [publicCollection.name, files.length],+ [publicCollection.name, albumDescription, files.length],);return (diff --git a/web/apps/photos/src/components/Collections/CollectionHeader.tsx b/web/apps/photos/src/components/Collections/CollectionHeader.tsxindex 317348c6d9..f4e4660c95 100644--- a/web/apps/photos/src/components/Collections/CollectionHeader.tsx+++ b/web/apps/photos/src/components/Collections/CollectionHeader.tsx@@ -86,12 +86,16 @@ export interface CollectionHeaderProps {hasActiveFileSelection: boolean;onAddSaveGroup: AddSaveGroup;onShowMap: () => void;+ onDescriptionHeightChange?: (height: number) => void;}export const CollectionHeader: React.FC<CollectionHeaderProps> = (props) => {- const { collectionSummary } = props;+ const { activeCollection, collectionSummary, onDescriptionHeightChange } =+ props;const { name, type, attributes, fileCount } = collectionSummary;+ const description =+ activeCollection?.pubMagicMetadata?.data.caption?.trim();const EndIcon = () => {if (attributes.has("archived")) return <ArchiveOutlinedIcon />;@@ -112,8 +116,12 @@ export const CollectionHeader: React.FC<CollectionHeaderProps> = (props) => {<SpacedRow><GalleryItemsSummaryname={name}+ description={description}+ descriptionMaxWidth={480}+ descriptionOpacity={0.9}fileCount={fileCount}endIcon={<EndIcon />}+ onDescriptionHeightChange={onDescriptionHeightChange}/>{shouldShowOptions(type) && (<CollectionHeaderOptions {...props} />diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsxindex cc0d3ddd1a..9d8a9368dc 100644--- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx+++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx@@ -21,6 +21,7 @@ import {} from "ente-gallery/components/utils/save-groups";import type { Collection } from "ente-media/collection";import {+ galleryItemsDescriptionHeight,GalleryItemsHeaderAdapter,GalleryItemsSummary,} from "ente-new/photos/components/gallery/ListHeader";@@ -34,7 +35,13 @@ import {} from "ente-new/photos/services/collection-summary";import type { Person } from "ente-new/photos/services/ml/people";import { includes } from "ente-utils/type-guards";-import React, { useCallback, useEffect, useMemo, useState } from "react";+import React, {+ useCallback,+ useEffect,+ useLayoutEffect,+ useMemo,+ useState,+} from "react";import { AlbumCastDialog } from "./AlbumCastDialog";import {CollectionHeader,@@ -157,7 +164,17 @@ export const GalleryBarAndListHeader: React.FC<return !!group && !isSaveComplete(group) && !isSaveCancelled(group);}, [saveGroups, activeCollectionID]);+ const albumDescription =+ activeCollection?.pubMagicMetadata?.data.caption?.trim();+ const [descriptionHeight, setDescriptionHeight] = useState(0);+useEffect(() => {+ setDescriptionHeight(+ albumDescription ? galleryItemsDescriptionHeight : 0,+ );+ }, [albumDescription]);++ useLayoutEffect(() => {if (shouldHide) return;const collectionSummary = toShowCollectionSummaries.get(@@ -187,6 +204,7 @@ export const GalleryBarAndListHeader: React.FC<onCollectionCast={showCollectionCast}onEditAlbumDetails={onEditAlbumDetails}hasActiveFileSelection={hasActiveFileSelection}+ onDescriptionHeightChange={setDescriptionHeight}/>) : mode != "people" && collectionSummary ? (<GalleryItemsHeaderAdapter>@@ -203,7 +221,7 @@ export const GalleryBarAndListHeader: React.FC<) : (<></>),- height: 68,+ height: 68 + descriptionHeight,});// eslint-disable-next-line react-hooks/exhaustive-deps}, [@@ -223,6 +241,7 @@ export const GalleryBarAndListHeader: React.FC<onAddSaveGroup,onShowMap,onEditAlbumDetails,+ descriptionHeight,// TODO: Cluster// This causes a loop since it is an array dep// people,diff --git a/web/apps/photos/src/components/FileList.tsx b/web/apps/photos/src/components/FileList.tsxindex fdcb9eddf4..460b7e7d86 100644--- a/web/apps/photos/src/components/FileList.tsx+++ b/web/apps/photos/src/components/FileList.tsx@@ -52,6 +52,7 @@ import React, {useCallback,useDeferredValue,useEffect,+ useLayoutEffect,useMemo,useRef,useState,@@ -327,9 +328,9 @@ export const FileList: React.FC<FileListProps> = ({layoutParams,]);- useEffect(() => {+ useLayoutEffect(() => {listRef.current?.resetAfterIndex(0);- }, [items]);+ }, [items, header?.height]);useEffect(() => {const notSelectedFiles = annotatedFiles.filter(@@ -731,8 +732,11 @@ export const FileList: React.FC<FileListProps> = ({);const itemSize = useCallback(- (index: number) => itemData.items[index]!.height,- [itemData],+ (index: number) =>+ index == 0 && header && itemData.items[0]?.type == "span"+ ? header.height+ : itemData.items[index]!.height,+ [header, itemData],);const itemKey = useCallback((index: number, itemData: FileListItemData) => {diff --git a/web/packages/new/photos/components/gallery/ListHeader.tsx b/web/packages/new/photos/components/gallery/ListHeader.tsxindex bce71a4456..9ef5696ab0 100644--- a/web/packages/new/photos/components/gallery/ListHeader.tsx+++ b/web/packages/new/photos/components/gallery/ListHeader.tsx@@ -5,26 +5,35 @@ import {Typography,type TypographyProps,} from "@mui/material";+import { isSxArray } from "ente-base/components/utils/sx";import { t } from "i18next";-import React from "react";+import React, { useEffect, useRef, useState } from "react";interface GalleryItemsSummaryProps {name: string;+ description?: string;+ descriptionMaxWidth?: number;+ descriptionOpacity?: number;nameProps?: TypographyProps;fileCount: number;endIcon?: React.ReactNode;// This cannot be the only way to invoke the action; it is mouse-only.onNameClick?: () => void;+ onDescriptionHeightChange?: (height: number) => void;}export const GalleryItemsSummary: React.FC<GalleryItemsSummaryProps> = ({name,+ description,+ descriptionMaxWidth,+ descriptionOpacity,nameProps,fileCount,endIcon,onNameClick,+ onDescriptionHeightChange,}) => (- <div>+ <Box sx={{ minWidth: 0 }}><Typography variant="h3" {...(nameProps ?? {})} onClick={onNameClick}>{name}</Typography>@@ -46,9 +55,131 @@ export const GalleryItemsSummary: React.FC<GalleryItemsSummaryProps> = ({</Box>)}</Stack>- </div>++ <AlbumDescription+ key={description}+ description={description}+ expandable={Boolean(onDescriptionHeightChange)}+ sx={{+ pt: "4px",+ maxWidth: descriptionMaxWidth ?? 420,+ color: "text.muted",+ opacity: descriptionOpacity,+ }}+ onHeightChange={onDescriptionHeightChange}+ />+ </Box>);+export const galleryItemsDescriptionHeight = 24;++interface AlbumDescriptionProps {+ description?: string;+ expandable?: boolean;+ sx?: TypographyProps["sx"];+ onHeightChange?: (height: number) => void;+}++export const AlbumDescription: React.FC<AlbumDescriptionProps> = ({+ description,+ expandable,+ sx,+ onHeightChange,+}) => {+ const [expansionState, setExpansionState] = useState<+ "collapsed" | "expanded" | "collapsing"+ >("collapsed");+ const [expandedHeight, setExpandedHeight] = useState(+ galleryItemsDescriptionHeight,+ );+ const textRef = useRef<HTMLElement>(null);++ useEffect(() => {+ const text = textRef.current;+ if (!text || (!expandable && !onHeightChange)) return;++ const report = () => {+ setExpandedHeight(text.scrollHeight);+ onHeightChange?.(text.offsetHeight);+ };+ report();+ const observer = new ResizeObserver(report);+ observer.observe(text);+ return () => observer.disconnect();+ }, [description, expandable, onHeightChange]);++ if (!description) return <></>;++ const handleToggle = () => {+ if (expansionState == "collapsed") {+ setExpansionState("expanded");+ } else if (expansionState == "expanded") {+ setExpansionState(+ matchMedia("(prefers-reduced-motion: reduce)").matches+ ? "collapsed"+ : "collapsing",+ );+ }+ };++ const handleTransitionEnd: React.TransitionEventHandler<HTMLElement> = (+ event,+ ) => {+ if (+ event.propertyName == "max-height" &&+ expansionState == "collapsing"+ )+ setExpansionState("collapsed");+ };++ return (+ <Typography+ component={expandable ? "button" : "p"}+ ref={(element: HTMLElement | null) => {+ textRef.current = element;+ }}+ type={expandable ? "button" : undefined}+ aria-expanded={+ expandable ? expansionState == "expanded" : undefined+ }+ onClick={expandable ? handleToggle : undefined}+ onTransitionEnd={expandable ? handleTransitionEnd : undefined}+ sx={[+ {+ display: "-webkit-box",+ overflow: "hidden",+ WebkitBoxOrient: "vertical",+ WebkitLineClamp:+ expansionState == "collapsed" ? 1 : "unset",+ overflowWrap: "anywhere",+ textWrap: "pretty",+ fontSize: "14px",+ lineHeight: "20px",+ ...(expandable && {+ border: 0,+ p: 0,+ background: "none",+ color: "inherit",+ textAlign: "left",+ cursor: "pointer",+ maxHeight:+ expansionState == "expanded"+ ? `${expandedHeight}px`+ : `${galleryItemsDescriptionHeight}px`,+ transition: "max-height 140ms ease-out",+ "@media (prefers-reduced-motion: reduce)": {+ transition: "none",+ },+ }),+ },+ ...(sx ? (isSxArray(sx) ? sx : [sx]) : []),+ ]}+ >+ {description}+ </Typography>+ );+};+export const GalleryItemsHeaderAdapter = styled("div")`width: 100%;margin-bottom: 12px;