Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix(photos):share-people-sort-order-with-overview

Aswin Asok1b5d9d7bca27
diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
index 77191317db..3e2ab0c185 100644
--- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
+++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
@@ -12,7 +12,7 @@ import {
type GalleryBarImplProps,
} from "@/components/gallery/BarImpl";
import { PeopleHeader } from "@/components/gallery/PeopleHeader";
-import { sortPeople, type PeopleSortBy } from "@/utils/people-sort";
+import { sortPeople } from "@/utils/people-sort";
import { useModalVisibility } from "ente-base/components/utils/modal";
import {
isSaveCancelled,
@@ -46,8 +46,6 @@ export type GalleryBarAndListHeaderProps = Omit<
| "onSelectCollectionID"
| "collectionsSortBy"
| "onChangeCollectionsSortBy"
- | "peopleSortBy"
- | "onChangePeopleSortBy"
| "onShowAllAlbums"
| "onShowAllPeople"
> & {
@@ -89,6 +87,8 @@ export const GalleryBarAndListHeader: React.FC<
setActiveCollectionID,
setBlockingLoad,
people,
+ peopleSortBy,
+ onChangePeopleSortBy,
onSelectPerson,
allPeople,
saveGroups,
@@ -134,8 +134,6 @@ export const GalleryBarAndListHeader: React.FC<
const [collectionsSortBy, setCollectionsSortBy] =
useCollectionsSortByLocalState("updation-time-desc");
- const [peopleSortBy, setPeopleSortBy] =
- useState<PeopleSortBy>("count-desc");
const sortedCollectionSummaries = useMemo(
() =>
@@ -276,7 +274,7 @@ export const GalleryBarAndListHeader: React.FC<
onSelectCollectionID={selectCollection}
onSelectPerson={selectPerson}
onChangeCollectionsSortBy={setCollectionsSortBy}
- onChangePeopleSortBy={setPeopleSortBy}
+ onChangePeopleSortBy={onChangePeopleSortBy}
onShowAllAlbums={showAllAlbums}
onShowAllPeople={showAllPeople}
collectionSummaries={sortedCollectionSummaries.filter(
@@ -312,7 +310,7 @@ export const GalleryBarAndListHeader: React.FC<
allPeople={allPeople}
onSelectPerson={selectPerson}
peopleSortBy={peopleSortBy}
- onChangePeopleSortBy={setPeopleSortBy}
+ onChangePeopleSortBy={onChangePeopleSortBy}
/>
{activeCollection && (
<>
diff --git a/web/apps/photos/src/components/gallery/PeopleOverview.tsx b/web/apps/photos/src/components/gallery/PeopleOverview.tsx
index 5fdbd07026..c4f1556834 100644
--- a/web/apps/photos/src/components/gallery/PeopleOverview.tsx
+++ b/web/apps/photos/src/components/gallery/PeopleOverview.tsx
@@ -1,4 +1,4 @@
-import { sortPeople } from "@/utils/people-sort";
+import { sortPeople, type PeopleSortBy } from "@/utils/people-sort";
import { Box, Stack, Typography, styled } from "@mui/material";
import { ItemCard } from "ente-new/photos/components/Tiles";
import { UnstyledButton } from "ente-new/photos/components/UnstyledButton";
@@ -9,14 +9,16 @@ import { PeopleEmptyState } from ".";
export const PeopleOverview = ({
people,
+ peopleSortBy,
onSelectPerson,
}: {
people: Person[];
+ peopleSortBy: PeopleSortBy;
onSelectPerson: (id: string) => void;
}) => {
const sortedPeople = useMemo(
- () => sortPeople(people, "count-desc"),
- [people],
+ () => sortPeople(people, peopleSortBy),
+ [people, peopleSortBy],
);
return (
<Stack
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 4b1006dc90..315f288814 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -58,6 +58,7 @@ import { useIsOffline } from "@/components/utils/use-is-offline";
import { shouldShowWhatsNew } from "@/services/changelog";
import exportService from "@/services/export";
import { processPendingAlbumJoin } from "@/services/join-album";
+import type { PeopleSortBy } from "@/utils/people-sort";
import CheckCircleIcon from "@mui/icons-material/CheckCircle";
import { Link, Typography } from "@mui/material";
import { sessionExpiredDialogAttributes } from "ente-accounts/components/utils/dialog";
@@ -213,6 +214,8 @@ const Page: React.FC = () => {
context: { mode: "albums", collectionID: PseudoCollectionID.all },
});
const [blockingLoad, setBlockingLoad] = useState(false);
+ const [peopleSortBy, setPeopleSortBy] =
+ useState<PeopleSortBy>("count-desc");
const [shouldDisableDropzone, setShouldDisableDropzone] = useState(false);
const [dragAndDropFiles, setDragAndDropFiles] = useState<FileWithPath[]>(
[],
@@ -2035,6 +2038,8 @@ const Page: React.FC = () => {
activeCollection: activeCollection!,
activeCollectionID: activeCollectionID!,
activePerson,
+ peopleSortBy,
+ onChangePeopleSortBy: setPeopleSortBy,
setFileListHeader,
saveGroups,
canCreateAlbum: !isInArchiveSection,
@@ -2131,6 +2136,7 @@ const Page: React.FC = () => {
!state.view.activePerson ? (
<PeopleOverview
people={state.view.visiblePeople}
+ peopleSortBy={peopleSortBy}
onSelectPerson={handleSelectPerson}
/>
) : (