mirror of
https://github.com/stashapp/stash.git
synced 2026-05-09 05:05:29 +02:00
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:
parent
26cd867a6a
commit
2ac751f928
2 changed files with 13 additions and 1 deletions
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Reference in a new issue