Skip to content

armgit / ente

Public Imported from GitHub
0

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

Fix trip cover to show unique location count instead of cluster count

anandbaburajan454e2079155e
diff --git a/web/apps/photos/src/components/TripLayout/MobileCover.tsx b/web/apps/photos/src/components/TripLayout/MobileCover.tsx
index fdc0d5e601..afe825a711 100644
--- a/web/apps/photos/src/components/TripLayout/MobileCover.tsx
+++ b/web/apps/photos/src/components/TripLayout/MobileCover.tsx
@@ -4,13 +4,12 @@ import type { JourneyPoint } from "./types";
interface MobileCoverProps {
journeyData: JourneyPoint[];
- photoClusters: JourneyPoint[][];
albumTitle?: string;
coverImageUrl?: string | null;
}
export const MobileCover = memo<MobileCoverProps>(
- ({ journeyData, photoClusters, albumTitle, coverImageUrl }) => {
+ ({ journeyData, albumTitle, coverImageUrl }) => {
const sortedData = [...journeyData].sort(
(a, b) =>
new Date(a.timestamp).getTime() -
@@ -30,6 +29,14 @@ export const MobileCover = memo<MobileCoverProps>(
year: "numeric",
});
+ // Count unique locations based on unique name+country combinations
+ const uniqueLocations = new Set(
+ journeyData
+ .filter((point) => point.name && point.country)
+ .map((point) => `${point.name}, ${point.country}`),
+ );
+ const locationCount = uniqueLocations.size;
+
return (
<MobileCoverContainer>
{coverImageUrl ? (
@@ -61,8 +68,8 @@ export const MobileCover = memo<MobileCoverProps>(
<>
<TripTitle>{albumTitle || "Trip"}</TripTitle>
<TripSubtitle>
- {monthYear} β€’ {diffDays} days β€’{" "}
- {photoClusters.length} locations
+ {monthYear} β€’ {diffDays} days β€’ {locationCount}{" "}
+ locations
</TripSubtitle>
</>
) : (
diff --git a/web/apps/photos/src/components/TripLayout/TripCover.tsx b/web/apps/photos/src/components/TripLayout/TripCover.tsx
index 3073876fab..9f8d65dbe0 100644
--- a/web/apps/photos/src/components/TripLayout/TripCover.tsx
+++ b/web/apps/photos/src/components/TripLayout/TripCover.tsx
@@ -5,13 +5,12 @@ import type { JourneyPoint } from "./types";
interface TripCoverProps {
journeyData: JourneyPoint[];
- photoClusters: JourneyPoint[][];
albumTitle?: string;
coverImageUrl?: string | null;
}
export const TripCover = memo<TripCoverProps>(
- ({ journeyData, photoClusters, albumTitle, coverImageUrl }) => {
+ ({ journeyData, albumTitle, coverImageUrl }) => {
const sortedData = [...journeyData].sort(
(a, b) =>
new Date(a.timestamp).getTime() -
@@ -31,6 +30,14 @@ export const TripCover = memo<TripCoverProps>(
year: "numeric",
});
+ // Count unique locations based on unique name+country combinations
+ const uniqueLocations = new Set(
+ journeyData
+ .filter((point) => point.name && point.country)
+ .map((point) => `${point.name}, ${point.country}`),
+ );
+ const locationCount = uniqueLocations.size;
+
return (
<CoverContainer>
<CoverImageContainer>
@@ -68,7 +75,7 @@ export const TripCover = memo<TripCoverProps>(
<TripTitle>{albumTitle || "Trip"}</TripTitle>
<TripSubtitle>
{monthYear} β€’ {diffDays} days β€’{" "}
- {photoClusters.length} locations
+ {locationCount} locations
</TripSubtitle>
</>
) : (
diff --git a/web/apps/photos/src/components/TripLayout/index.tsx b/web/apps/photos/src/components/TripLayout/index.tsx
index f2044c9aa4..40d6ce1d91 100644
--- a/web/apps/photos/src/components/TripLayout/index.tsx
+++ b/web/apps/photos/src/components/TripLayout/index.tsx
@@ -375,7 +375,6 @@ export const TripLayout: React.FC<TripLayoutProps> = ({
<MobileCoverOverlay show={showMobileCover}>
<MobileCover
journeyData={journeyData}
- photoClusters={photoClusters}
albumTitle={collectionTitle}
coverImageUrl={coverImageUrl}
/>
@@ -478,7 +477,6 @@ export const TripLayout: React.FC<TripLayoutProps> = ({
<div>
<TripCover
journeyData={journeyData}
- photoClusters={photoClusters}
albumTitle={collectionTitle}
coverImageUrl={coverImageUrl}
/>