diff --git a/src/components/PhotoSwipe/index.tsx b/src/components/PhotoSwipe/index.tsx index a6768990a..4487ebf51 100644 --- a/src/components/PhotoSwipe/index.tsx +++ b/src/components/PhotoSwipe/index.tsx @@ -280,6 +280,9 @@ function PhotoSwipe(props: Iprops) { const updateItems = (items = []) => { if (photoSwipe) { + if (items.length === 0) { + photoSwipe.close(); + } photoSwipe.items.length = 0; items.forEach((item) => { photoSwipe.items.push(item); @@ -287,6 +290,9 @@ function PhotoSwipe(props: Iprops) { photoSwipe.invalidateCurrItems(); if (isOpen) { photoSwipe.updateSize(true); + if (photoSwipe.getCurrentIndex() >= photoSwipe.items.length) { + photoSwipe.goTo(0); + } } } }; @@ -375,16 +381,19 @@ function PhotoSwipe(props: Iprops) { className="pswp__button pswp__button--close" title={constants.CLOSE} /> - + {!props.isSharedCollection && + !props.isTrashCollection && ( + + )} {props.enableDownload && (