File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -630,8 +630,30 @@ public final class InfiniteQuery<
630630 /// Initial fetch for the first page
631631 /// This resets the query data and fetches from the beginning
632632 public func internalFetch( ) async throws -> InfiniteData < TData , TPageParam > {
633- // Reset to initial state to clear all existing pages
634- setState ( initialState)
633+ // Reset data but preserve status for refetch scenarios
634+ // Only use pending status if we've never successfully fetched data
635+ let resetState : QueryState < InfiniteData < TData , TPageParam > > = if state. dataUpdateCount > 0 {
636+ // This is a refetch - preserve success status to avoid isLoading becoming true
637+ QueryState (
638+ data: InfiniteData < TData , TPageParam > ( ) ,
639+ dataUpdateCount: state. dataUpdateCount,
640+ dataUpdatedAt: state. dataUpdatedAt,
641+ error: nil ,
642+ errorUpdateCount: state. errorUpdateCount,
643+ errorUpdatedAt: state. errorUpdatedAt,
644+ fetchFailureCount: 0 ,
645+ fetchFailureReason: nil ,
646+ fetchMeta: nil ,
647+ isInvalidated: false ,
648+ status: . success, // Preserve success status for refetch
649+ fetchStatus: . idle
650+ )
651+ } else {
652+ // First fetch - use initial state with pending status
653+ initialState
654+ }
655+
656+ setState ( resetState)
635657
636658 let initialParam = options. initialPageParam
637659 return try await fetchPage ( param: initialParam, direction: . forward)
You can’t perform that action at this time.
0 commit comments