Skip to content

Commit dc309fc

Browse files
Hoang Phamclaude
andcommitted
Fix pull-to-refresh behavior in infinite queries
- Reset infinite query data before fetching first page in internalFetch() - Prevents pull-to-refresh from appending first page to existing data - Ensures proper full data refresh when user pulls to refresh - Maintains expected behavior for infinite query refetch operations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4c4bf4d commit dc309fc

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Sources/SwiftUIQuery/InfiniteQuery.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,11 @@ public final class InfiniteQuery<
628628
}
629629

630630
/// Initial fetch for the first page
631+
/// This resets the query data and fetches from the beginning
631632
public func internalFetch() async throws -> InfiniteData<TData, TPageParam> {
633+
// Reset to initial state to clear all existing pages
634+
setState(initialState)
635+
632636
let initialParam = options.initialPageParam
633637
return try await fetchPage(param: initialParam, direction: .forward)
634638
}

0 commit comments

Comments
 (0)