Skip to content

armgit / ente

Public Imported from GitHub
0

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

[web][photos] Move people sorting into gallery page

AswinAsoka38d814d19af
diff --git a/web/apps/photos/src/components/collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/collections/GalleryBarAndListHeader.tsx
index 0b29ead13e..7bf69b2e70 100644
--- a/web/apps/photos/src/components/collections/GalleryBarAndListHeader.tsx
+++ b/web/apps/photos/src/components/collections/GalleryBarAndListHeader.tsx
@@ -10,7 +10,6 @@ import {
type GalleryBarImplProps,
} from "@/components/gallery/BarImpl";
import { PeopleHeader } from "@/components/gallery/PeopleHeader";
-import { sortPeople } from "@/utils/people-sort";
import { useModalVisibility } from "ente-base/components/utils/modal";
import {
isSaveCancelled,
@@ -26,7 +25,7 @@ import {
PseudoCollectionID,
type CollectionSummaries,
} from "ente-new/photos/services/collection-summary";
-import React, { useCallback, useEffect, useMemo, useState } from "react";
+import React, { useCallback, useEffect, useState } from "react";
import { AlbumCastDialog } from "./AlbumCastDialog";
import {
CollectionHeader,
@@ -34,6 +33,7 @@ import {
} from "./CollectionHeader";
export type GalleryBarAndListHeaderProps = GalleryBarImplProps & {
+ sortedPeople: GalleryBarImplProps["people"];
shouldHide: boolean;
barCollectionSummaries: CollectionSummaries;
activeCollection: Collection | undefined;
@@ -76,6 +76,7 @@ export const GalleryBarAndListHeader: React.FC<
onSelectCollectionID,
setBlockingLoad,
people,
+ sortedPeople,
peopleSortBy,
onChangePeopleSortBy,
albumFilter,
@@ -122,11 +123,6 @@ export const GalleryBarAndListHeader: React.FC<
collectionShareVisibilityProps.onClose();
}, [collectionShareVisibilityProps]);
- const sortedPeople = useMemo(
- () => sortPeople(people, peopleSortBy),
- [people, peopleSortBy],
- );
-
const isActiveCollectionDownloadInProgress = useCallback(() => {
const group = saveGroups.find(
(g) => g.collectionSummaryID === activeCollectionID,
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index d770ba1388..5a2464831d 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -66,7 +66,7 @@ import {
visibleAlbumFilters,
type AlbumFilter,
} from "@/utils/album-filters";
-import type { PeopleSortBy } from "@/utils/people-sort";
+import { sortPeople, type PeopleSortBy } from "@/utils/people-sort";
import { visibleQuickLinks } from "@/utils/quick-links";
import CheckCircleIcon from "@mui/icons-material/CheckCircle";
import { Link, Typography } from "@mui/material";
@@ -500,6 +500,13 @@ const Page: React.FC = () => {
);
const activePerson =
state.view?.type == "people" ? state.view.activePerson : undefined;
+ const people =
+ (state.view?.type == "people" ? state.view.visiblePeople : undefined) ??
+ [];
+ const sortedPeople = useMemo(
+ () => sortPeople(people, peopleSortBy),
+ [people, peopleSortBy],
+ );
const activePersonID = activePerson?.id;
const fileCollectionIDs = useMemo(
() =>
@@ -2200,10 +2207,8 @@ const Page: React.FC = () => {
emailByUserID: state.emailByUserID,
shareSuggestionEmails:
state.shareSuggestionEmails,
- people:
- (state.view?.type == "people"
- ? state.view.visiblePeople
- : undefined) ?? [],
+ people,
+ sortedPeople,
setBlockingLoad,
setActiveCollectionID:
barMode == "links"
diff --git a/web/apps/photos/tests/sidebar-quick-links.test.tsx b/web/apps/photos/tests/sidebar-quick-links.test.tsx
index 154213caaa..0cfc29b64c 100644
--- a/web/apps/photos/tests/sidebar-quick-links.test.tsx
+++ b/web/apps/photos/tests/sidebar-quick-links.test.tsx
@@ -65,6 +65,7 @@ const renderSidebar = (
barCollectionSummaries: new Map(summaries.map((cs) => [cs.id, cs])),
uncategorizedCollectionSummaryID: 99,
people: [],
+ sortedPeople: [],
peopleSortBy: "name-asc",
saveGroups: [],
setActiveCollectionID: vi.fn(),