π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[web][photos] Restore description-only header height handling
AswinAsokd306caa8d8ca
diff --git a/web/apps/photos/src/components/collections/CollectionHeader.tsx b/web/apps/photos/src/components/collections/CollectionHeader.tsxindex 80e7e303c8..b6cd49b643 100644--- a/web/apps/photos/src/components/collections/CollectionHeader.tsx+++ b/web/apps/photos/src/components/collections/CollectionHeader.tsx@@ -80,7 +80,7 @@ import {import { emptyTrash } from "ente-new/photos/services/trash";import { usePhotosAppContext } from "ente-new/photos/types/context";import { t } from "i18next";-import React, { useCallback, useEffect, useRef, useState } from "react";+import React, { useCallback, useRef, useState } from "react";import { Trans } from "react-i18next";export interface CollectionHeaderProps {@@ -98,26 +98,14 @@ export interface CollectionHeaderProps {onAddSaveGroup: AddSaveGroup;onShowMap: () => void;onBackToAlbums: () => void;- onHeightChange?: (height: number) => void;+ onDescriptionHeightChange?: (height: number) => void;}export const CollectionHeader: React.FC<CollectionHeaderProps> = (props) => {- const { activeCollection, collectionSummary, onHeightChange } = props;- const headerRef = useRef<HTMLDivElement>(null);+ const { activeCollection, collectionSummary, onDescriptionHeightChange } =+ props;const showCover = useMediaQuery(useTheme().breakpoints.up("sm"));- useEffect(() => {- const header = headerRef.current;- if (!header || !onHeightChange) return;- // Include the adapter's bottom margin in the virtualized header height.- const report = () =>- onHeightChange(Math.max(72, header.offsetHeight + 12));- report();- const observer = new ResizeObserver(report);- observer.observe(header);- return () => observer.disconnect();- }, [onHeightChange]);-const { name, type, attributes, fileCount } = collectionSummary;const isAlbum = isAlbumSummary(collectionSummary);const description =@@ -145,7 +133,7 @@ export const CollectionHeader: React.FC<CollectionHeaderProps> = (props) => {};return (- <GalleryItemsHeaderAdapter ref={headerRef}>+ <GalleryItemsHeaderAdapter><SpacedRowsx={isAlbum@@ -201,6 +189,9 @@ export const CollectionHeader: React.FC<CollectionHeaderProps> = (props) => {name={name}description={isAlbum ? undefined : description}descriptionMaxWidth={480}+ onDescriptionHeightChange={+ isAlbum ? undefined : onDescriptionHeightChange+ }fileCount={fileCount}endIcon={<EndIcon />}/>@@ -213,6 +204,7 @@ export const CollectionHeader: React.FC<CollectionHeaderProps> = (props) => {{isAlbum && (<AlbumDescriptiondescription={description}+ onHeightChange={onDescriptionHeightChange}sx={{gridArea: "description",pt: 1,diff --git a/web/apps/photos/src/components/collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/collections/GalleryBarAndListHeader.tsxindex 6b18031a01..bc0ede89f6 100644--- a/web/apps/photos/src/components/collections/GalleryBarAndListHeader.tsx+++ b/web/apps/photos/src/components/collections/GalleryBarAndListHeader.tsx@@ -98,7 +98,9 @@ export const GalleryBarAndListHeader: React.FC<collectionShareVisibilityProps.onClose();}, [collectionShareVisibilityProps]);- const [headerHeight, setHeaderHeight] = useState(72);+ const albumDescription =+ activeCollection?.pubMagicMetadata?.data.caption?.trim();+ const [descriptionHeight, setDescriptionHeight] = useState(0);useEffect(() => {if (shouldHide || mode == "links") return;@@ -129,7 +131,7 @@ export const GalleryBarAndListHeader: React.FC<onCollectionCast={showCollectionCast}onEditAlbumDetails={onEditAlbumDetails}hasActiveFileSelection={hasActiveFileSelection}- onHeightChange={setHeaderHeight}+ onDescriptionHeightChange={setDescriptionHeight}/>) : mode != "people" && collectionSummary ? (<GalleryItemsHeaderAdapter>@@ -141,17 +143,13 @@ export const GalleryBarAndListHeader: React.FC<) : activePerson ? (<PeopleHeaderperson={activePerson}- onHeightChange={setHeaderHeight}people={people}onSelectPerson={onSelectPerson}/>) : (<></>),- height:- shouldRenderCollectionHeader || activePerson- ? headerHeight- : 72,+ height: 72 + (albumDescription ? descriptionHeight : 0),});// eslint-disable-next-line react-hooks/exhaustive-deps}, [@@ -172,7 +170,8 @@ export const GalleryBarAndListHeader: React.FC<onCollectionSlideshow,onBackToAlbums,onEditAlbumDetails,- headerHeight,+ albumDescription,+ descriptionHeight,// TODO: Cluster// This causes a loop since it is an array dep// people,diff --git a/web/apps/photos/src/components/gallery/PeopleHeader.tsx b/web/apps/photos/src/components/gallery/PeopleHeader.tsxindex 4e41eb4cd4..2c9790eed1 100644--- a/web/apps/photos/src/components/gallery/PeopleHeader.tsx+++ b/web/apps/photos/src/components/gallery/PeopleHeader.tsx@@ -81,34 +81,21 @@ import type {PreviewableCluster,} from "ente-new/photos/services/ml/people";import { t } from "i18next";-import React, { useEffect, useReducer, useRef, useState } from "react";+import React, { useEffect, useReducer, useState } from "react";import type { GalleryBarImplProps } from "./BarImpl";type PeopleHeaderProps = Pick<GalleryBarImplProps,"people" | "onSelectPerson"-> & { person: Person; onHeightChange?: (height: number) => void };+> & { person: Person };export const PeopleHeader: React.FC<PeopleHeaderProps> = ({people,onSelectPerson,person,- onHeightChange,}) => {- const headerRef = useRef<HTMLDivElement>(null);- useEffect(() => {- const header = headerRef.current;- if (!header || !onHeightChange) return;- const report = () =>- onHeightChange(Math.max(72, header.offsetHeight + 12));- report();- const observer = new ResizeObserver(report);- observer.observe(header);- return () => observer.disconnect();- }, [onHeightChange]);-return (- <GalleryItemsHeaderAdapter ref={headerRef}>+ <GalleryItemsHeaderAdapter><SpacedRow sx={{ gap: 2 }}>{person.type == "cgroup" ? (person.isHidden ? (