Skip to content

armgit / ente

Public Imported from GitHub
0

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

chore: linting

anandbaburajan5b061fca0e3c
diff --git a/web/apps/photos/src/components/TripLayout/TripMap.tsx b/web/apps/photos/src/components/TripLayout/TripMap.tsx
index fb3399f870..796cc1ad0e 100644
--- a/web/apps/photos/src/components/TripLayout/TripMap.tsx
+++ b/web/apps/photos/src/components/TripLayout/TripMap.tsx
@@ -83,7 +83,9 @@ export const TripMap: React.FC<TripMapProps> = ({
targetZoom,
mapRef,
optimalZoom,
- currentActiveLocationIndex >= 0 ? currentActiveLocationIndex : undefined,
+ currentActiveLocationIndex >= 0
+ ? currentActiveLocationIndex
+ : undefined,
);
return (
diff --git a/web/apps/photos/src/components/TripLayout/index.tsx b/web/apps/photos/src/components/TripLayout/index.tsx
index 4676f43671..5cf60956d1 100644
--- a/web/apps/photos/src/components/TripLayout/index.tsx
+++ b/web/apps/photos/src/components/TripLayout/index.tsx
@@ -156,7 +156,11 @@ export const TripLayout: React.FC<TripLayoutProps> = ({
// Load mapHelpers and calculate clusters if we have data
if (journeyData.length > 0) {
void import("./mapHelpers").then(
- ({ clusterPhotosByProximity, calculateOptimalZoom, detectScreenCollisions }) => {
+ ({
+ clusterPhotosByProximity,
+ calculateOptimalZoom,
+ detectScreenCollisions,
+ }) => {
const clusters = clusterPhotosByProximity(journeyData);
// Sort clusters by their earliest timestamp to maintain chronological order
@@ -187,16 +191,29 @@ export const TripLayout: React.FC<TripLayoutProps> = ({
);
// Create a map of cluster index to super cluster index
- const clusterToSuperClusterMap = new Map<number, number>();
- superClusters.forEach((superCluster, superClusterIndex) => {
- superCluster.clustersInvolved.forEach((clusterIndex) => {
- clusterToSuperClusterMap.set(clusterIndex, superClusterIndex);
- });
- });
+ const clusterToSuperClusterMap = new Map<
+ number,
+ number
+ >();
+ superClusters.forEach(
+ (superCluster, superClusterIndex) => {
+ superCluster.clustersInvolved.forEach(
+ (clusterIndex) => {
+ clusterToSuperClusterMap.set(
+ clusterIndex,
+ superClusterIndex,
+ );
+ },
+ );
+ },
+ );
setPhotoClusters(sortedClusters);
setOptimalZoom(optimalZoomLevel);
- setSuperClusterInfo({ superClusters, clusterToSuperClusterMap });
+ setSuperClusterInfo({
+ superClusters,
+ clusterToSuperClusterMap,
+ });
},
);
}
diff --git a/web/apps/photos/src/components/TripLayout/mapHelpers.ts b/web/apps/photos/src/components/TripLayout/mapHelpers.ts
index 4bddf7da28..4df27c6e79 100644
--- a/web/apps/photos/src/components/TripLayout/mapHelpers.ts
+++ b/web/apps/photos/src/components/TripLayout/mapHelpers.ts
@@ -241,7 +241,8 @@ export const createSuperClusterIcon = (
return positions;
};
- const backgroundMarkerPositions = generateStackedMarkerPositions(clusterCount);
+ const backgroundMarkerPositions =
+ generateStackedMarkerPositions(clusterCount);
const icon = leaflet.divIcon({
html: `
@@ -251,7 +252,9 @@ export const createSuperClusterIcon = (
position: relative;
cursor: pointer;
">
- ${backgroundMarkerPositions.map((pos, index) => `
+ ${backgroundMarkerPositions
+ .map(
+ (pos, index) => `
<!-- Background marker ${index} -->
<div style="
position: absolute;
@@ -295,7 +298,9 @@ export const createSuperClusterIcon = (
border-top: ${triangleHeight}px solid ${isReached ? "#22c55e" : "white"};
"></div>
</div>
- `).join('')}
+ `,
+ )
+ .join("")}
<!-- Main pin container -->
<div class="photo-pin${isReached ? " reached" : ""}" style="
@@ -445,7 +450,8 @@ export const detectScreenCollisions = (
// If we found overlapping clusters, create a super-cluster
// But only if none of the involved clusters is the currently active cluster
- const involvesActiveCluster = activeClusterIndex !== undefined &&
+ const involvesActiveCluster =
+ activeClusterIndex !== undefined &&
overlappingClusters.includes(activeClusterIndex);
if (overlappingClusters.length > 1 && !involvesActiveCluster) {
@@ -529,7 +535,8 @@ export const getMapCenter = (
// At zoom 10, approximately 0.35 degrees per 1000px at equator
// For positioning, we need to shift the longitude to place marker at desired position
const degreesPerPixelAtZoom10 = 0.35 / 1000; // rough approximation
- const basePixelsToShift = (window.innerWidth || 1400) * (1 - timelineWidthRatio);
+ const basePixelsToShift =
+ (window.innerWidth || 1400) * (1 - timelineWidthRatio);
const pixelsToShiftFor20Percent = isMobile
? basePixelsToShift * 0.6 // Mobile: less aggressive positioning (60% instead of 300%)
: basePixelsToShift * 3.0; // Desktop: 300% of visible map width to shift map left
@@ -554,7 +561,8 @@ export const getLocationPosition = (
// Calculate shift to position marker at 20% from right edge of visible map
// Need to shift map center left so the marker appears more to the right
// On mobile, use less aggressive positioning since we have full width
- const basePixelsToShift = (window.innerWidth || 1400) * (1 - timelineWidthRatio);
+ const basePixelsToShift =
+ (window.innerWidth || 1400) * (1 - timelineWidthRatio);
const pixelsToShiftFor20Percent = isMobile
? basePixelsToShift * 0.6 // Mobile: less aggressive positioning (60% instead of 300%)
: basePixelsToShift * 3.0; // Desktop: 300% of visible map width to shift map left
@@ -578,11 +586,13 @@ export const getLocationPositionAtZoom = (
// At higher zoom levels, we need less offset since we're more zoomed in
const baseDegreesPerPixelAtZoom10 = 0.35 / 1000;
const zoomScaleFactor = Math.pow(2, 10 - zoom); // Scale relative to zoom 10
- const degreesPerPixelAtCurrentZoom = baseDegreesPerPixelAtZoom10 * zoomScaleFactor;
+ const degreesPerPixelAtCurrentZoom =
+ baseDegreesPerPixelAtZoom10 * zoomScaleFactor;
// Calculate shift to position marker at 20% from right edge of visible map
// On mobile, use less aggressive positioning since we have full width
- const basePixelsToShift = (window.innerWidth || 1400) * (1 - timelineWidthRatio);
+ const basePixelsToShift =
+ (window.innerWidth || 1400) * (1 - timelineWidthRatio);
const pixelsToShiftFor20Percent = isMobile
? basePixelsToShift * 0.6 // Mobile: less aggressive positioning (60% instead of 300%)
: basePixelsToShift * 3.0; // Desktop: 300% of visible map width to shift map left
diff --git a/web/apps/photos/src/components/TripLayout/utils/scrollUtils.ts b/web/apps/photos/src/components/TripLayout/utils/scrollUtils.ts
index b5a58525b3..886e0cdedd 100644
--- a/web/apps/photos/src/components/TripLayout/utils/scrollUtils.ts
+++ b/web/apps/photos/src/components/TripLayout/utils/scrollUtils.ts
@@ -1,6 +1,10 @@
import { startTransition } from "react";
-import { calculateDistance, getLocationPosition, getLocationPositionAtZoom } from "../mapHelpers";
+import {
+ calculateDistance,
+ getLocationPosition,
+ getLocationPositionAtZoom,
+} from "../mapHelpers";
import type { JourneyPoint } from "../types";
export interface PositionInfo {
@@ -174,14 +178,19 @@ export const handleTimelineScroll = ({
const targetZoom = isTouchDevice ? 8 : 10; // Touch device-aware zoom level
// Use pre-calculated super cluster info instead of recalculating
- const currentSuperClusterIndex = superClusterInfo.clusterToSuperClusterMap.get(currentActiveLocationIndex) ?? -1;
+ const currentSuperClusterIndex =
+ superClusterInfo.clusterToSuperClusterMap.get(
+ currentActiveLocationIndex,
+ ) ?? -1;
const isInSuperCluster = currentSuperClusterIndex !== -1;
// Check previous super cluster state
const previousState = previousSuperClusterStateRef.current;
const wasInSuperCluster = previousState.isInSuperCluster;
const previousSuperClusterIndex = previousState.superClusterIndex;
- const isSameSuperCluster = isInSuperCluster && wasInSuperCluster &&
+ const isSameSuperCluster =
+ isInSuperCluster &&
+ wasInSuperCluster &&
currentSuperClusterIndex === previousSuperClusterIndex;
try {
@@ -193,7 +202,7 @@ export const handleTimelineScroll = ({
const [zoomAwareLat, zoomAwareLng] = getLocationPositionAtZoom(
targetCluster.lat,
targetCluster.lng,
- superClusterZoom
+ superClusterZoom,
);
// First zoom out far for distant locations
@@ -206,11 +215,11 @@ export const handleTimelineScroll = ({
// Then zoom back in to super cluster level
setTimeout(() => {
setTargetZoom(superClusterZoom);
- mapRef.flyTo([zoomAwareLat, zoomAwareLng], superClusterZoom, {
- animate: true,
- duration: 1.2,
- easeLinearity: 0.25,
- });
+ mapRef.flyTo(
+ [zoomAwareLat, zoomAwareLng],
+ superClusterZoom,
+ { animate: true, duration: 1.2, easeLinearity: 0.25 },
+ );
}, 1600);
} else if (isInSuperCluster && !wasInSuperCluster) {
// Entering super cluster from nearby location - direct zoom in
@@ -218,7 +227,7 @@ export const handleTimelineScroll = ({
const [zoomAwareLat, zoomAwareLng] = getLocationPositionAtZoom(
targetCluster.lat,
targetCluster.lng,
- superClusterZoom
+ superClusterZoom,
);
setTargetZoom(superClusterZoom);
mapRef.flyTo([zoomAwareLat, zoomAwareLng], superClusterZoom, {
@@ -231,19 +240,23 @@ export const handleTimelineScroll = ({
if (isDistantLocation) {
// Distant location: full zoom out β†’ pan β†’ zoom in
const intermediateZoom = isTouchDevice ? 2 : 4;
- mapRef.flyTo([positionedLat, positionedLng], intermediateZoom, {
- animate: true,
- duration: 1.5,
- easeLinearity: 0.25,
- });
+ mapRef.flyTo(
+ [positionedLat, positionedLng],
+ intermediateZoom,
+ { animate: true, duration: 1.5, easeLinearity: 0.25 },
+ );
setTimeout(() => {
setTargetZoom(targetZoom);
- mapRef.flyTo([positionedLat, positionedLng], targetZoom, {
- animate: true,
- duration: 1.2,
- easeLinearity: 0.25,
- });
+ mapRef.flyTo(
+ [positionedLat, positionedLng],
+ targetZoom,
+ {
+ animate: true,
+ duration: 1.2,
+ easeLinearity: 0.25,
+ },
+ );
}, 1600);
} else {
// Nearby location: direct zoom out to normal view
@@ -260,7 +273,7 @@ export const handleTimelineScroll = ({
const [zoomAwareLat, zoomAwareLng] = getLocationPositionAtZoom(
targetCluster.lat,
targetCluster.lng,
- currentMapZoom
+ currentMapZoom,
);
mapRef.panTo([zoomAwareLat, zoomAwareLng], {
animate: true,
@@ -270,7 +283,8 @@ export const handleTimelineScroll = ({
} else if (isInSuperCluster) {
// In super cluster but different from previous - treat as distant location
// Check if we're switching between different super clusters
- const isDifferentSuperCluster = wasInSuperCluster &&
+ const isDifferentSuperCluster =
+ wasInSuperCluster &&
currentSuperClusterIndex !== previousSuperClusterIndex;
if (isDistantLocation) {
@@ -278,18 +292,19 @@ export const handleTimelineScroll = ({
// Since we're in the isInSuperCluster block, destination is always a super cluster
const finalZoom = isTouchDevice ? 15 : 14; // Higher zoom on mobile to break apart clusters
const intermediateZoom = isTouchDevice ? 2 : 4; // Extreme zoom out for distant locations
- const [zoomAwareLat, zoomAwareLng] = getLocationPositionAtZoom(
- targetCluster.lat,
- targetCluster.lng,
- finalZoom
- );
+ const [zoomAwareLat, zoomAwareLng] =
+ getLocationPositionAtZoom(
+ targetCluster.lat,
+ targetCluster.lng,
+ finalZoom,
+ );
// First zoom out far for distant locations
- mapRef.flyTo([zoomAwareLat, zoomAwareLng], intermediateZoom, {
- animate: true,
- duration: 1.5,
- easeLinearity: 0.25,
- });
+ mapRef.flyTo(
+ [zoomAwareLat, zoomAwareLng],
+ intermediateZoom,
+ { animate: true, duration: 1.5, easeLinearity: 0.25 },
+ );
// Then zoom back in to appropriate level (super cluster or normal)
setTimeout(() => {
@@ -304,36 +319,42 @@ export const handleTimelineScroll = ({
// Different super cluster (not distant): moderate zoom out β†’ pan β†’ zoom in
const superClusterZoom = isTouchDevice ? 15 : 14; // Higher zoom on mobile to break apart clusters
const intermediateZoom = isTouchDevice ? 8 : 10; // Moderate zoom out for nearby super clusters
- const [zoomAwareLat, zoomAwareLng] = getLocationPositionAtZoom(
- targetCluster.lat,
- targetCluster.lng,
- superClusterZoom
- );
+ const [zoomAwareLat, zoomAwareLng] =
+ getLocationPositionAtZoom(
+ targetCluster.lat,
+ targetCluster.lng,
+ superClusterZoom,
+ );
// First zoom out moderately
- mapRef.flyTo([zoomAwareLat, zoomAwareLng], intermediateZoom, {
- animate: true,
- duration: 0.8,
- easeLinearity: 0.25,
- });
+ mapRef.flyTo(
+ [zoomAwareLat, zoomAwareLng],
+ intermediateZoom,
+ { animate: true, duration: 0.8, easeLinearity: 0.25 },
+ );
// Then zoom back in to super cluster level
setTimeout(() => {
setTargetZoom(superClusterZoom);
- mapRef.flyTo([zoomAwareLat, zoomAwareLng], superClusterZoom, {
- animate: true,
- duration: 0.8,
- easeLinearity: 0.25,
- });
+ mapRef.flyTo(
+ [zoomAwareLat, zoomAwareLng],
+ superClusterZoom,
+ {
+ animate: true,
+ duration: 0.8,
+ easeLinearity: 0.25,
+ },
+ );
}, 900);
} else {
// Same super cluster, different location - just pan with zoom-aware positioning
const currentMapZoom = mapRef.getZoom();
- const [zoomAwareLat, zoomAwareLng] = getLocationPositionAtZoom(
- targetCluster.lat,
- targetCluster.lng,
- currentMapZoom
- );
+ const [zoomAwareLat, zoomAwareLng] =
+ getLocationPositionAtZoom(
+ targetCluster.lat,
+ targetCluster.lng,
+ currentMapZoom,
+ );
mapRef.panTo([zoomAwareLat, zoomAwareLng], {
animate: true,
duration: 0.6,
@@ -377,7 +398,7 @@ export const handleTimelineScroll = ({
// Update super cluster state
previousSuperClusterStateRef.current = {
isInSuperCluster,
- superClusterIndex: currentSuperClusterIndex
+ superClusterIndex: currentSuperClusterIndex,
};
} catch (error) {
console.warn("Map operation failed:", error);