Merge pull request #746 from ente-io/deleting-last-image-from-photoswipe
fix photoswipe delete option issues
This commit is contained in:
commit
b92af56fdc
|
@ -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}
|
||||
/>
|
||||
<button
|
||||
className="pswp__button pswp__button--custom"
|
||||
title={constants.DELETE}
|
||||
onClick={() => {
|
||||
confirmTrashFile(
|
||||
photoSwipe?.currItem as EnteFile
|
||||
);
|
||||
}}>
|
||||
<DeleteIcon fontSize="small" />
|
||||
</button>
|
||||
{!props.isSharedCollection &&
|
||||
!props.isTrashCollection && (
|
||||
<button
|
||||
className="pswp__button pswp__button--custom"
|
||||
title={constants.DELETE}
|
||||
onClick={() => {
|
||||
confirmTrashFile(
|
||||
photoSwipe?.currItem as EnteFile
|
||||
);
|
||||
}}>
|
||||
<DeleteIcon fontSize="small" />
|
||||
</button>
|
||||
)}
|
||||
|
||||
{props.enableDownload && (
|
||||
<button
|
||||
|
|
Loading…
Reference in a new issue