Skip to content

Commit 5f03285

Browse files
authored
fix: photo viewer logic to use filtered photos for opening (#161)
1 parent 46e573c commit 5f03285

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

apps/web/src/components/ui/map/shared/PhotoMarkerPin.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export const PhotoMarkerPin = ({ marker, isSelected = false, onClick, onClose }:
114114
<div className="space-y-3 p-4">
115115
{/* Title with link */}
116116
<Link
117-
to={`/${marker.photo.id}`}
117+
to={`/photos/${marker.photo.id}`}
118118
target="_blank"
119119
className="group/link hover:text-blue flex items-center gap-2 transition-colors"
120120
>

apps/web/src/pages/(main)/layout.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { photoLoader } from '@afilmory/data'
21
import { ScrollArea, ScrollElementContext } from '@afilmory/ui'
32
import { useAtomValue, useSetAtom } from 'jotai'
43
import { useEffect, useRef } from 'react'
@@ -67,13 +66,6 @@ const useStateRestoreFromUrl = () => {
6766
triggerOnceRef.current = true
6867
isRestored = true
6968

70-
if (photoId) {
71-
const photo = photoLoader.getPhotos().find((photo) => photo.id === photoId)
72-
if (photo) {
73-
openViewer(photoLoader.getPhotos().indexOf(photo))
74-
}
75-
}
76-
7769
const tagsFromSearchParams = searchParams.get('tags')?.split(',')
7870
const camerasFromSearchParams = searchParams.get('cameras')?.split(',')
7971
const lensesFromSearchParams = searchParams.get('lenses')?.split(',')
@@ -96,6 +88,15 @@ const useStateRestoreFromUrl = () => {
9688
tagFilterMode: tagModeFromSearchParams || prev.tagFilterMode,
9789
}))
9890
}
91+
92+
if (photoId) {
93+
const filteredPhotos = getFilteredPhotos()
94+
const targetIndex = filteredPhotos.findIndex((photo) => photo.id === photoId)
95+
96+
if (targetIndex !== -1) {
97+
openViewer(targetIndex)
98+
}
99+
}
99100
}, [openViewer, photoId, searchParams, setGallerySetting])
100101
}
101102

0 commit comments

Comments
 (0)