From 74491a45a9ec764e9ebca2d5605d680ab1208882 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Mon, 27 Apr 2026 10:33:31 +0200 Subject: [PATCH] fix(repoList): prevent duplicate entries from concurrent loadMore calls Add isLoading guard so concurrent fetches are rejected, and include isLoading in canLoadMore so vInfiniteScroll waits before firing again. --- src/hooks/useRepos.hook.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/hooks/useRepos.hook.ts b/src/hooks/useRepos.hook.ts index 213dde1..5cc51b1 100644 --- a/src/hooks/useRepos.hook.ts +++ b/src/hooks/useRepos.hook.ts @@ -9,6 +9,7 @@ const STALE_TIME_MS = 20 * 60 * 1000 const repos = ref([]) const isReady = ref(false) +const isLoading = ref(false) const hasCredentialError = ref(false) const currentPage = ref(0) const totalCount = ref(0) @@ -22,6 +23,8 @@ export const useRepos = () => { isReady.value = true return } + if (isLoading.value) return + isLoading.value = true try { const octokit = await getOctokit() const nextPage = currentPage.value + 1 @@ -53,10 +56,13 @@ export const useRepos = () => { } } finally { isReady.value = true + isLoading.value = false } } - const canLoadMore = computed(() => repos.value.length < totalCount.value) + const canLoadMore = computed( + () => !isLoading.value && repos.value.length < totalCount.value + ) const isStale = Date.now() - lastFetchedAt > STALE_TIME_MS if (!isReady.value || isStale) { @@ -65,6 +71,7 @@ export const useRepos = () => { currentPage.value = 0 totalCount.value = 0 isReady.value = false + isLoading.value = false hasCredentialError.value = false } lastFetchedAt = Date.now()