Skip to content

Commit 236edc8

Browse files
committed
fix loading photos on paginated
1 parent b7948a9 commit 236edc8

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

resources/js/components/pagination/PaginationInfiniteScroll.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ let scrollContainer: HTMLElement | null = null;
4040
*/
4141
function handleIntersect(entries: IntersectionObserverEntry[]) {
4242
const entry = entries[0];
43-
console.debug(
44-
`[InfiniteScroll] intersect: isIntersecting=${entry.isIntersecting}, hasMore=${props.hasMore}, loading=${props.loading}, isEmitting=${isEmitting}`,
45-
);
43+
if (LycheeState.is_debug_enabled) {
44+
console.debug(
45+
`[InfiniteScroll] intersect: isIntersecting=${entry.isIntersecting}, hasMore=${props.hasMore}, loading=${props.loading}, isEmitting=${isEmitting}`,
46+
);
47+
}
4648
// Guard against duplicate emissions during rapid intersection callbacks
4749
if (entry.isIntersecting && props.hasMore && !props.loading && !isEmitting) {
4850
// console.log("[InfiniteScroll] => emitting loadMore");

resources/js/views/gallery-panels/Album.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,8 @@ watch(
495495
496496
photoStore.setTransition(newPhotoId as string | undefined);
497497
498-
if (newAlbumId !== albumStore.albumId) {
498+
const oldAlbumId = albumId.value;
499+
if (newAlbumId !== oldAlbumId) {
499500
current_page.value = 1; // Reset the page if we change album
500501
}
501502
albumId.value = newAlbumId as string;
@@ -506,6 +507,18 @@ watch(
506507
togglableStore.rememberScrollThumb(photoId.value);
507508
}
508509
510+
if (oldAlbumId === newAlbumId) {
511+
// If we are navigating between photos of the same album, we don't need to reload the album.
512+
// We just need to load the new photo.
513+
photoStore.load();
514+
515+
// TODO: Consider loading the next page if the photo is getting close to the end of the currently loaded photos.
516+
return;
517+
}
518+
519+
// If we are navigating to a different album, we need to
520+
// 1. load the new album
521+
// 2. set the scroll position to the photo if we have a photoId, or to the top if we don't have a photoId
509522
load().then(() => {
510523
if (photoId.value === undefined) {
511524
setScroll();

0 commit comments

Comments
 (0)