Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix(CollectionMapDialog):fix-cover-header-memo

Aswin Asok92c3be1e492b
diff --git a/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx b/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx
index a238937258..09cca359d9 100644
--- a/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionMapDialog.tsx
@@ -1305,20 +1305,30 @@ function CollectionSidebar({
(collectionSummary.coverFile &&
thumbByFileID.get(collectionSummary.coverFile.id)) ||
(latestFileId ? thumbByFileID.get(latestFileId) : undefined);
- const coverHeader = shouldShowCover
- ? {
- component: (
- <MapCover
- name={collectionSummary.name}
- coverImageUrl={coverImageUrl}
- totalCount={collectionSummary.fileCount}
- onClose={onClose}
- />
- ),
- height: COVER_HEADER_HEIGHT,
- extendToInlineEdges: true,
- }
- : undefined;
+ const coverHeader = useMemo(
+ () =>
+ shouldShowCover
+ ? {
+ component: (
+ <MapCover
+ name={collectionSummary.name}
+ coverImageUrl={coverImageUrl}
+ totalCount={collectionSummary.fileCount}
+ onClose={onClose}
+ />
+ ),
+ height: COVER_HEADER_HEIGHT,
+ extendToInlineEdges: true,
+ }
+ : undefined,
+ [
+ shouldShowCover,
+ collectionSummary.name,
+ collectionSummary.fileCount,
+ coverImageUrl,
+ onClose,
+ ],
+ );
const showStickyHeader =
!shouldShowCover ||
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index a69cbf6d19..f571f70b62 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -623,11 +623,6 @@ const Page: React.FC = () => {
void router.push(href, undefined, { shallow: true });
}, [activeCollectionID, router.isReady]);
- // The map dialog is only mounted when there is an active collection
- // summary, and MUI only invokes onClose for escape / backdrop dismissal,
- // so if the user navigates somewhere without one (e.g. to a person) while
- // the map is open, the open flag would stay latched and the map would
- // reopen on the next visit to an albums view unless we reset it here.
useEffect(() => {
if (!activeCollectionSummary) closeCollectionMap();
}, [activeCollectionSummary, closeCollectionMap]);
@@ -1478,9 +1473,6 @@ const Page: React.FC = () => {
[],
);
- // These can be invoked from the file viewer hosted by the map dialog, so
- // close the map (if open) to land the user in the gallery grid instead of
- // silently swapping the contents of the still open map.
const handleSelectCollection = useCallback(
(collectionID: number) => {
closeCollectionMap();