diff --git a/apps/photos/src/components/pages/gallery/PreviewCard.tsx b/apps/photos/src/components/pages/gallery/PreviewCard.tsx index 8bc49d0ae..4e0ac402e 100644 --- a/apps/photos/src/components/pages/gallery/PreviewCard.tsx +++ b/apps/photos/src/components/pages/gallery/PreviewCard.tsx @@ -218,6 +218,12 @@ export default function PreviewCard(props: IProps) { const galleryContext = useContext(GalleryContext); const deduplicateContext = useContext(DeduplicateContext); + const longPressCallback = () => { + onSelect(!selected); + }; + + const longPress = useLongPress(longPressCallback, 500); + const { file, onClick, @@ -289,9 +295,6 @@ export default function PreviewCard(props: IProps) { } }; - const longPressCallback = () => { - onSelect(!selected); - }; const handleHover = () => { if (isRangeSelectActive) { onHover(); @@ -304,7 +307,7 @@ export default function PreviewCard(props: IProps) { onClick={handleClick} onMouseEnter={handleHover} disabled={!file?.msrc && !imgSrc} - {...(selectable ? useLongPress(longPressCallback, 500) : {})}> + {...(selectable ? longPress : {})}> {selectable && ( { + if (!selected?.count) { + return; + } + setSelected({ ownCount: 0, count: 0, collectionID: 0 }); + }; + const downloadFilesHelper = async () => { try { const selectedFiles = getSelectedFiles(selected, publicFiles); @@ -518,18 +525,12 @@ export default function PublicCollectionGallery() { selectedFiles, setFilesDownloadProgressAttributes ); + clearSelection(); } catch (e) { logError(e, 'failed to download selected files'); } }; - const clearSelection = () => { - if (!selected?.count) { - return; - } - setSelected({ ownCount: 0, count: 0, collectionID: 0 }); - }; - return (