Skip to content

armgit / ente

Public Imported from GitHub
0

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

Use

Manav Rathi7644900bd8fb
diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
index 0e9c83dde4..882879e7ba 100644
--- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
+++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
@@ -9,7 +9,6 @@ import {
type CollectionsSortBy,
type CollectionSummaries,
} from "@/new/photos/types/collection";
-import { ensure } from "@/utils/ensure";
import { includes } from "@/utils/type-guards";
import {
getData,
@@ -95,7 +94,7 @@ export const GalleryBarAndListHeader: React.FC<CollectionsProps> = ({
setActiveCollectionID,
hiddenCollectionSummaries,
people,
- activePersonID,
+ activePerson,
onSelectPerson,
setCollectionNamerAttributes,
setPhotoListHeader,
@@ -173,10 +172,7 @@ export const GalleryBarAndListHeader: React.FC<CollectionsProps> = ({
/>
) : (
<PeopleHeader
- person={ensure(
- people.find((p) => p.id == activePersonID) ??
- people[0],
- )}
+ person={activePerson}
{...{ onSelectPerson, appContext }}
/>
),
@@ -190,7 +186,7 @@ export const GalleryBarAndListHeader: React.FC<CollectionsProps> = ({
activeCollectionID,
isActiveCollectionDownloadInProgress,
people,
- activePersonID,
+ activePerson,
]);
if (shouldBeHidden) {
@@ -205,7 +201,7 @@ export const GalleryBarAndListHeader: React.FC<CollectionsProps> = ({
onChangeMode,
activeCollectionID,
people,
- activePersonID,
+ activePerson,
onSelectPerson,
collectionsSortBy,
}}
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 02e1fe97d7..fb516fe35b 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -575,11 +575,10 @@ export default function Gallery() {
}))
.filter((p) => p.fileIDs.length > 0);
}
- const activePerson = ensure(
+ const activePerson =
filteredPeople.find((p) => p.id == activePersonID) ??
- filteredPeople[0],
- );
- const pfSet = new Set(activePerson.fileIDs);
+ filteredPeople[0];
+ const pfSet = new Set(activePerson?.fileIDs ?? []);
filteredFiles = getUniqueFiles(
files.filter(({ id }) => {
if (!pfSet.has(id)) return false;
@@ -728,8 +727,11 @@ export default function Gallery() {
count: 0,
collectionID: activeCollectionID,
context:
- barMode == "people" && activePersonID
- ? { mode: "people" as const, personID: activePersonID }
+ barMode == "people" && galleryPeopleState?.activePersonID
+ ? {
+ mode: "people" as const,
+ personID: galleryPeopleState.activePersonID,
+ }
: {
mode: "albums" as const,
collectionID: ensure(activeCollectionID),
@@ -1107,7 +1109,7 @@ export default function Gallery() {
// when the user clicks the "People" header in the search empty state (it
// is guaranteed that this header will only be shown if there is at
// least one person).
- setActivePersonID(person?.id ?? ensure(people[0]).id);
+ setActivePersonID(person?.id ?? galleryPeopleState?.people[0]?.id);
setBarMode("people");
};
@@ -1219,8 +1221,9 @@ export default function Gallery() {
activeCollectionID,
setActiveCollectionID,
hiddenCollectionSummaries,
- people,
- activePersonID,
+ people: galleryPeopleState?.people,
+ activePersonID: galleryPeopleState?.activePersonID,
+ activePerson: galleryPeopleState?.activePerson,
onSelectPerson: handleSelectPerson,
setCollectionNamerAttributes,
setPhotoListHeader,
@@ -1296,7 +1299,7 @@ export default function Gallery() {
setTempDeletedFileIds={setTempDeletedFileIds}
setIsPhotoSwipeOpen={setIsPhotoSwipeOpen}
activeCollectionID={activeCollectionID}
- activePersonID={activePersonID}
+ activePersonID={galleryPeopleState?.activePersonID}
enableDownload={true}
fileToCollectionsMap={fileToCollectionsMap}
collectionNameMap={collectionNameMap}
diff --git a/web/packages/new/photos/components/Gallery/BarImpl.tsx b/web/packages/new/photos/components/Gallery/BarImpl.tsx
index 80a65e8dde..c71ee1fc62 100644
--- a/web/packages/new/photos/components/Gallery/BarImpl.tsx
+++ b/web/packages/new/photos/components/Gallery/BarImpl.tsx
@@ -94,11 +94,11 @@ export interface GalleryBarImplProps {
*/
people: Person[];
/**
- * The ID of the currently selected person.
+ * The currently selected person.
*
* Required if mode is "people".
*/
- activePersonID: string | undefined;
+ activePerson: Person | undefined;
/**
* Called when the selection should be moved to a new person in the bar, or
* reset to the default state (when {@link person} is `undefined`).
@@ -116,7 +116,7 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({
collectionsSortBy,
onChangeCollectionsSortBy,
people,
- activePersonID,
+ activePerson,
onSelectPerson,
}) => {
const isMobile = useIsMobileWidth();
@@ -194,11 +194,11 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({
);
break;
case "people":
- i = people.findIndex(({ id }) => id == activePersonID);
+ i = people.findIndex(({ id }) => id == activePerson?.id);
break;
}
if (i != -1) listRef.current.scrollToItem(i, "smart");
- }, [mode, collectionSummaries, activeCollectionID, people, activePersonID]);
+ }, [mode, collectionSummaries, activeCollectionID, people, activePerson]);
const itemData = useMemo<ItemData>(
() =>
@@ -210,12 +210,9 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({
onSelectCollectionID,
}
: {
- type: "people",
+ type: "people" as const,
people,
- activePerson: ensure(
- people.find((p) => p.id == activePersonID) ??
- people[0],
- ),
+ activePerson: ensure(activePerson),
onSelectPerson,
},
[
@@ -224,7 +221,7 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({
activeCollectionID,
onSelectCollectionID,
people,
- activePersonID,
+ activePerson,
onSelectPerson,
],
);