Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ui/v2.5/src/components/Scenes/SceneMarkerWallPanel.tsx
Original file line number Diff line number Diff line change
@@ -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, {
Expand Down Expand Up @@ -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]
Expand Down
6 changes: 6 additions & 0 deletions ui/v2.5/src/components/Scenes/SceneWallPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down