Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ let scrollContainer: HTMLElement | null = null;
*/
function handleIntersect(entries: IntersectionObserverEntry[]) {
const entry = entries[0];
console.debug(
`[InfiniteScroll] intersect: isIntersecting=${entry.isIntersecting}, hasMore=${props.hasMore}, loading=${props.loading}, isEmitting=${isEmitting}`,
);
if (LycheeState.is_debug_enabled) {
console.debug(
`[InfiniteScroll] intersect: isIntersecting=${entry.isIntersecting}, hasMore=${props.hasMore}, loading=${props.loading}, isEmitting=${isEmitting}`,
);
}
// Guard against duplicate emissions during rapid intersection callbacks
if (entry.isIntersecting && props.hasMore && !props.loading && !isEmitting) {
// console.log("[InfiniteScroll] => emitting loadMore");
Expand Down
15 changes: 14 additions & 1 deletion resources/js/views/gallery-panels/Album.vue
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@ watch(

photoStore.setTransition(newPhotoId as string | undefined);

if (newAlbumId !== albumStore.albumId) {
const oldAlbumId = albumId.value;
if (newAlbumId !== oldAlbumId) {
current_page.value = 1; // Reset the page if we change album
}
albumId.value = newAlbumId as string;
Expand All @@ -506,6 +507,18 @@ watch(
togglableStore.rememberScrollThumb(photoId.value);
}

if (oldAlbumId === newAlbumId) {
// If we are navigating between photos of the same album, we don't need to reload the album.
// We just need to load the new photo.
photoStore.load();

// TODO: Consider loading the next page if the photo is getting close to the end of the currently loaded photos.
return;
}

// If we are navigating to a different album, we need to
// 1. load the new album
// 2. set the scroll position to the photo if we have a photoId, or to the top if we don't have a photoId
load().then(() => {
if (photoId.value === undefined) {
setScroll();
Expand Down
Loading