fix(ui): prevent duplicate history entry when clicking wall items

Clicking a scene or marker in the wall view pushes two identical history
entries, requiring the user to press back twice to return to the wall.
This is caused by react-photo-gallery dispatching the onClick handler
twice for a single click event.

Add a timestamp-based guard to deduplicate clicks within 100ms.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Speck Pratt 2026-04-14 08:36:57 -04:00
parent 26cd867a6a
commit 2ac751f928
2 changed files with 13 additions and 1 deletions

View file

@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useMemo, useState } from "react";
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { Form } from "react-bootstrap";
import * as GQL from "src/core/generated-graphql";
import Gallery, {
@ -243,8 +243,14 @@ const MarkerWall: React.FC<IMarkerWallProps> = ({
});
}, [markers, erroredImgs, handleError]);
// Guard against duplicate clicks - react-photo-gallery can dispatch
// the onClick handler twice for a single click event
const lastClickTime = useRef(0);
const onClick = useCallback(
(event, { index }) => {
const now = Date.now();
if (now - lastClickTime.current < 100) return;
lastClickTime.current = now;
history.push(photos[index].link);
},
[history, photos]

View file

@ -258,8 +258,14 @@ const SceneWall: React.FC<ISceneWallProps> = ({
});
}, [scenes, sceneQueue, erroredImgs, handleError]);
// Guard against duplicate clicks - react-photo-gallery can dispatch
// the onClick handler twice for a single click event
const lastClickTime = useRef(0);
const onClick = useCallback(
(event, { index }) => {
const now = Date.now();
if (now - lastClickTime.current < 100) return;
lastClickTime.current = now;
history.push(photos[index].link);
},
[history, photos]