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