add error handling to updateItems and refreshPhotoswipe
This commit is contained in:
parent
4af9ee5bed
commit
fc677f3419
|
@ -400,6 +400,7 @@ function PhotoViewer(props: Iprops) {
|
|||
};
|
||||
|
||||
const updateItems = (items = []) => {
|
||||
try {
|
||||
if (photoSwipe) {
|
||||
if (items.length === 0) {
|
||||
photoSwipe.close();
|
||||
|
@ -408,21 +409,31 @@ function PhotoViewer(props: Iprops) {
|
|||
items.forEach((item) => {
|
||||
photoSwipe.items.push(item);
|
||||
});
|
||||
|
||||
photoSwipe.invalidateCurrItems();
|
||||
if (isOpen) {
|
||||
photoSwipe.updateSize(true);
|
||||
if (photoSwipe.getCurrentIndex() >= photoSwipe.items.length) {
|
||||
if (
|
||||
photoSwipe.getCurrentIndex() >= photoSwipe.items.length
|
||||
) {
|
||||
photoSwipe.goTo(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
logError(e, 'updateItems failed');
|
||||
}
|
||||
};
|
||||
|
||||
const refreshPhotoswipe = () => {
|
||||
try {
|
||||
photoSwipe.invalidateCurrItems();
|
||||
if (isOpen) {
|
||||
photoSwipe.updateSize(true);
|
||||
}
|
||||
} catch (e) {
|
||||
logError(e, 'refreshPhotoswipe failed');
|
||||
}
|
||||
};
|
||||
|
||||
const checkExifAvailable = async (file: EnteFile) => {
|
||||
|
|
Loading…
Reference in a new issue