Merge pull request #746 from ente-io/deleting-last-image-from-photoswipe

fix photoswipe delete option issues
This commit is contained in:
Abhinav Kumar 2022-10-19 13:51:53 +05:30 committed by GitHub
commit b92af56fdc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,6 +381,8 @@ function PhotoSwipe(props: Iprops) {
className="pswp__button pswp__button--close"
title={constants.CLOSE}
/>
{!props.isSharedCollection &&
!props.isTrashCollection && (
<button
className="pswp__button pswp__button--custom"
title={constants.DELETE}
@ -385,6 +393,7 @@ function PhotoSwipe(props: Iprops) {
}}>
<DeleteIcon fontSize="small" />
</button>
)}
{props.enableDownload && (
<button