@@ -23,6 +23,7 @@ const MAX_RESULTS = 250
2323 */
2424export function useUserPackages ( username : MaybeRefOrGetter < string > ) {
2525 const { searchProvider } = useSearchProvider ( )
26+ // this is only used in npm path, but we need to extract it when the composable runs
2627 const { $npmRegistry } = useNuxtApp ( )
2728 const { searchByOwner } = useAlgoliaSearch ( )
2829
@@ -103,7 +104,11 @@ export function useUserPackages(username: MaybeRefOrGetter<string>) {
103104 { default : ( ) => emptySearchResponse } ,
104105 )
105106 // --- Fetch more (npm path only) ---
106- async function fetchMore ( ) : Promise < void > {
107+ /**
108+ * Fetch the next page of results from npm registry.
109+ * @param manageLoadingState - When false, caller manages isLoadingMore (used by loadAll to prevent flicker)
110+ */
111+ async function fetchMore ( manageLoadingState = true ) : Promise < void > {
107112 const user = toValue ( username )
108113 const provider = searchProvider . value
109114 if ( ! user || provider !== 'npm' ) return
@@ -119,7 +124,7 @@ export function useUserPackages(username: MaybeRefOrGetter<string>) {
119124
120125 if ( currentCount >= total ) return
121126
122- isLoadingMore . value = true
127+ if ( manageLoadingState ) isLoadingMore . value = true
123128
124129 try {
125130 const from = currentCount
@@ -155,7 +160,7 @@ export function useUserPackages(username: MaybeRefOrGetter<string>) {
155160 }
156161 }
157162 } finally {
158- isLoadingMore . value = false
163+ if ( manageLoadingState ) isLoadingMore . value = false
159164 }
160165 }
161166
@@ -173,7 +178,7 @@ export function useUserPackages(username: MaybeRefOrGetter<string>) {
173178 isLoadingMore . value = true
174179 try {
175180 while ( hasMore . value ) {
176- await fetchMore ( )
181+ await fetchMore ( false )
177182 }
178183 } finally {
179184 isLoadingMore . value = false
@@ -184,7 +189,6 @@ export function useUserPackages(username: MaybeRefOrGetter<string>) {
184189 watch ( searchProvider , ( ) => {
185190 cache . value = null
186191 currentPage . value = 1
187- asyncData . refresh ( )
188192 } )
189193
190194 // Computed data that uses cache
0 commit comments