Skip to content

Commit

Permalink
fix: reset scroll ids when gallery is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
jakowenko committed Jun 22, 2023
1 parent a9015d0 commit 24a05e6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions frontend/src/views/GalleryView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const modal = ref<{ show: boolean; src: string; image: { [name: string]: any };
});
const fixed: Ref<HTMLElement | null> = ref(null);
const loading = ref(true);
const scrollIds: number[] = [];
const scrollIds = ref<number[]>([]);
const galleries = ref<Gallery[]>([]);
const oldestGalleryId = ref(0);
const favoritesDefault = ref(false);
Expand Down Expand Up @@ -154,6 +154,7 @@ const getGallery = async (firstLoad?: boolean) => {
total.value = data.total;
hasMore.value = data.hasMore;
updateGalleryIds();
scrollIds.value = [];
loading.value = false;
} catch (error) {
emitter.emit('error', error);
Expand Down Expand Up @@ -189,8 +190,8 @@ const handleScroll = async () => {
const totalScrollableHeight = document.documentElement.scrollHeight - window.innerHeight;
if (window.scrollY + 50 >= totalScrollableHeight) {
const { id: beforeId } = galleries.value[galleries.value.length - 1];
if (scrollIds.includes(beforeId)) return;
scrollIds.push(beforeId);
if (scrollIds.value.includes(beforeId)) return;
scrollIds.value.push(beforeId);
getMoreGallery();
}
};
Expand Down

0 comments on commit 24a05e6

Please sign in to comment.