fix: preview navigation walks the timeline's visible order
Previously the preview view walked the raw API photos array for arrow navigation and the filmstrip. In tag-grouped mode (and any future layout where the visible grid order diverges from the API sort) that diverged from the order the user actually saw — they'd hit ← / → and land on a photo that wasn't adjacent in the grid. Fix: Timeline publishes its flat visible-order id sequence into the photo store as visiblePhotoIds whenever its layout items change (including duplicates from tag buckets, which is what the user wants in tag mode — landing on a photo's second appearance in the next bucket is the right behavior). PreviewView resolves that sequence back to Photo objects via the rawPhotos map and uses the result for both arrow nav and the filmstrip. Falls back to the raw photos list when the sequence isn't populated yet. Also clean up the lingering hardcoded http://localhost:8001 in usePhotosQuery — switched to the shared axios instance with the relative /api/v1 baseURL so the hook works cross-machine through the nginx / vite proxy. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -172,6 +172,7 @@ export function Timeline() {
|
||||
togglePhotoSelection,
|
||||
clearSelection,
|
||||
openPreview,
|
||||
setVisiblePhotoIds,
|
||||
} = usePhotoStore()
|
||||
|
||||
const sortBy = useFilterStore((s) => s.sortBy)
|
||||
@@ -294,6 +295,21 @@ export function Timeline() {
|
||||
[items]
|
||||
)
|
||||
|
||||
// Publish the flat visible-order id sequence to the photo store so
|
||||
// PreviewView arrow nav (and the filmstrip) walks the same order the
|
||||
// user sees in the grid. Includes duplicates from tag grouping —
|
||||
// landing on the same photo's "second" appearance in the next tag
|
||||
// bucket is the right behavior in tag mode.
|
||||
useEffect(() => {
|
||||
const ids: string[] = []
|
||||
for (const row of photoRows) {
|
||||
for (const cell of row.cells) {
|
||||
ids.push(cell.photo.id)
|
||||
}
|
||||
}
|
||||
setVisiblePhotoIds(ids)
|
||||
}, [photoRows, setVisiblePhotoIds])
|
||||
|
||||
// Locate the active photo in the visual grid. Returns the FIRST
|
||||
// (rowIndex, colIndex) where its id appears, since a tag-grouped view
|
||||
// can repeat a photo across groups. Returns null when there's no
|
||||
|
||||
Reference in New Issue
Block a user