Skip to content

armgit / ente

Public Imported from GitHub
0

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

Deduplicate active location index calculation in TripMap

anandbaburajan9fe8d3a7f8ec
diff --git a/web/apps/photos/src/components/TripLayout/TripMap.tsx b/web/apps/photos/src/components/TripLayout/TripMap.tsx
index 0596790184..52ad05b461 100644
--- a/web/apps/photos/src/components/TripLayout/TripMap.tsx
+++ b/web/apps/photos/src/components/TripLayout/TripMap.tsx
@@ -136,23 +136,9 @@ export const TripMap: React.FC<TripMapProps> = ({
{/* Draw super-clusters (clickable for zoom and gallery) */}
{superClusters.map((superCluster, index) => {
// Show green only for active locations
- let currentLocationIndex;
- if (isTouchDevice) {
- // Mobile: Slower progression - stay on each location longer
- currentLocationIndex = Math.floor(
- scrollProgress * (photoClusters.length - 0.5),
- );
- } else {
- // Desktop: Use original logic
- currentLocationIndex = Math.round(
- scrollProgress *
- Math.max(0, photoClusters.length - 1),
- );
- }
- const isActive =
- superCluster.clustersInvolved.includes(
- currentLocationIndex,
- );
+ const isActive = superCluster.clustersInvolved.includes(
+ currentActiveLocationIndex,
+ );
const icon = createSuperClusterIcon(
superCluster.image, // Use representative photo (first photo of first cluster)
@@ -198,21 +184,8 @@ export const TripMap: React.FC<TripMapProps> = ({
// Use the preserved original index
const originalClusterIndex = originalIndex;
// Show green only for active locations
- let currentLocationIndex;
- if (isTouchDevice) {
- // Mobile: Slower progression - stay on each location longer
- currentLocationIndex = Math.floor(
- scrollProgress * (photoClusters.length - 0.5),
- );
- } else {
- // Desktop: Use original logic
- currentLocationIndex = Math.round(
- scrollProgress *
- Math.max(0, photoClusters.length - 1),
- );
- }
const isActive =
- originalClusterIndex === currentLocationIndex;
+ originalClusterIndex === currentActiveLocationIndex;
const icon = createIcon(
firstPhoto.image,
diff --git a/web/apps/photos/src/components/TripLayout/index.tsx b/web/apps/photos/src/components/TripLayout/index.tsx
index f3a7a7b142..947f7a0fff 100644
--- a/web/apps/photos/src/components/TripLayout/index.tsx
+++ b/web/apps/photos/src/components/TripLayout/index.tsx
@@ -197,7 +197,6 @@ export const TripLayout: React.FC<TripLayoutProps> = ({
null,
null,
optimalZoomLevel,
- undefined, // No active cluster during initial calculation
);
// Create a map of cluster index to super cluster index