import React, { useRef, useState, useCallback, useEffect } from "react"; import Avatar from "../../components/common/Avatar"; import ImagePopup from "./ImagePopup"; const ImageGalleryListView = ({ images, isLoading, isFetchingNextPage, hasNextPage, loaderRef, openModal, formatUTCToLocalTime, moment, }) => { const [hoveredImage, setHoveredImage] = useState(null); const [scrollThreshold, setScrollThreshold] = useState(5); const imageGroupRefs = useRef({}); useEffect(() => { const updateThreshold = () => { if (window.innerWidth >= 1400) setScrollThreshold(6); else if (window.innerWidth >= 992) setScrollThreshold(5); else if (window.innerWidth >= 768) setScrollThreshold(4); else setScrollThreshold(3); }; updateThreshold(); window.addEventListener("resize", updateThreshold); return () => window.removeEventListener("resize", updateThreshold); }, []); const scrollLeft = useCallback( (key) => imageGroupRefs.current[key]?.scrollBy({ left: -200, behavior: "smooth" }), [] ); const scrollRight = useCallback( (key) => imageGroupRefs.current[key]?.scrollBy({ left: 200, behavior: "smooth" }), [] ); if (!images.length && !isLoading) { return
No images match the selected filters.
; } return (Date: {hoverDate}
Time: {hoverTime}
Activity: {batch.activityName}
Loading...
} {!hasNextPage && !isLoading && images.length > 0 && (You've reached the end of the images.
)}