Skip to content

armgit / ente

Public Imported from GitHub
0

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

Don't used cached data

Manav Rathi91127b6ce5f2
diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
index c15d15553e..b423698edb 100644
--- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
+++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
@@ -95,7 +95,7 @@ export const GalleryBarAndListHeader: React.FC<CollectionsProps> = ({
setActiveCollectionID,
hiddenCollectionSummaries,
people,
- activePerson,
+ activePersonID,
onSelectPerson,
setCollectionNamerAttributes,
setPhotoListHeader,
@@ -173,7 +173,9 @@ export const GalleryBarAndListHeader: React.FC<CollectionsProps> = ({
/>
) : (
<PeopleHeader
- person={ensure(activePerson)}
+ person={ensure(
+ people.find((p) => p.id == activePersonID),
+ )}
appContext={appContext}
/>
),
@@ -187,7 +189,7 @@ export const GalleryBarAndListHeader: React.FC<CollectionsProps> = ({
activeCollectionID,
isActiveCollectionDownloadInProgress,
people,
- activePerson,
+ activePersonID,
]);
if (shouldBeHidden) {
@@ -202,7 +204,7 @@ export const GalleryBarAndListHeader: React.FC<CollectionsProps> = ({
onChangeMode,
activeCollectionID,
people,
- activePerson,
+ activePersonID,
onSelectPerson,
collectionsSortBy,
}}
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 3a784d8ad6..cb1cba1f38 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -317,8 +317,8 @@ export default function Gallery() {
// If visible, what should the (sticky) gallery bar show.
const [barMode, setBarMode] = useState<GalleryBarMode>("albums");
- // The currently selected person in the gallery bar (if any).
- const [activePerson, setActivePerson] = useState<Person | undefined>();
+ // The ID of the currently selected person in the gallery bar (if any).
+ const [activePersonID, setActivePersonID] = useState<string | undefined>();
const people = useSyncExternalStore(peopleSubscribe, peopleSnapshot);
@@ -552,7 +552,10 @@ export default function Gallery() {
selectedSearchOption.suggestion,
);
} else if (barMode == "people") {
- const pfSet = new Set(ensure(activePerson).fileIDs);
+ const activePerson = ensure(
+ people.find((p) => p.id == activePersonID),
+ );
+ const pfSet = new Set(activePerson.fileIDs);
filteredFiles = getUniqueFiles(
files.filter(({ id }) => {
if (!pfSet.has(id)) return false;
@@ -642,7 +645,8 @@ export default function Gallery() {
selectedSearchOption,
activeCollectionID,
archivedCollections,
- activePerson,
+ people,
+ activePersonID,
]);
const selectAll = (e: KeyboardEvent) => {
@@ -675,8 +679,8 @@ export default function Gallery() {
count: 0,
collectionID: activeCollectionID,
context:
- barMode == "people" && activePerson
- ? { mode: "people" as const, personID: activePerson.id }
+ barMode == "people" && activePersonID
+ ? { mode: "people" as const, personID: activePersonID }
: {
mode: "albums" as const,
collectionID: ensure(activeCollectionID),
@@ -996,7 +1000,7 @@ export default function Gallery() {
setActiveCollectionID(searchOption.suggestion.collectionID);
} else {
setBarMode("people");
- setActivePerson(searchOption.suggestion.person);
+ setActivePersonID(searchOption.suggestion.person.id);
}
} else {
setIsInSearchMode(!!searchOption);
@@ -1054,7 +1058,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).
- setActivePerson(person ?? ensure(people[0]));
+ setActivePersonID(person.id ?? ensure(people[0]).id);
setBarMode("people");
};
@@ -1167,7 +1171,7 @@ export default function Gallery() {
setActiveCollectionID,
hiddenCollectionSummaries,
people,
- activePerson,
+ activePersonID,
onSelectPerson: handleSelectPerson,
setCollectionNamerAttributes,
setPhotoListHeader,
@@ -1243,7 +1247,7 @@ export default function Gallery() {
setTempDeletedFileIds={setTempDeletedFileIds}
setIsPhotoSwipeOpen={setIsPhotoSwipeOpen}
activeCollectionID={activeCollectionID}
- activePersonID={activePerson?.id}
+ activePersonID={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 2a00d342a8..92e951b96e 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 currently selected person.
+ * The ID of the currently selected person.
*
* Required if mode is "people".
*/
- activePerson: Person | undefined;
+ activePersonID: string | undefined;
/**
* Called when the user selects a new person in the bar.
*/
@@ -115,7 +115,7 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({
collectionsSortBy,
onChangeCollectionsSortBy,
people,
- activePerson,
+ activePersonID,
onSelectPerson,
}) => {
const isMobile = useIsMobileWidth();
@@ -193,11 +193,11 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({
);
break;
case "people":
- i = people.findIndex(({ id }) => id == activePerson?.id);
+ i = people.findIndex(({ id }) => id == activePersonID);
break;
}
if (i != -1) listRef.current.scrollToItem(i, "smart");
- }, [mode, collectionSummaries, activeCollectionID, people, activePerson]);
+ }, [mode, collectionSummaries, activeCollectionID, people, activePersonID]);
const itemData = useMemo<ItemData>(
() =>
@@ -211,7 +211,9 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({
: {
type: "people",
people,
- activePerson: ensure(activePerson),
+ activePerson: ensure(
+ people.find((p) => p.id == activePersonID),
+ ),
onSelectPerson,
},
[
@@ -220,7 +222,7 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({
activeCollectionID,
onSelectCollectionID,
people,
- activePerson,
+ activePersonID,
onSelectPerson,
],
);