Skip to content

Fix useLiveQuery loading status in on-demand sync - #962

Closed
KyleAMathews wants to merge 22 commits into
mainfrom
claude/fix-livequery-loading-status-01TNsEPERmfs3ub3e9iDRAzK
Closed

Fix useLiveQuery loading status in on-demand sync#962
KyleAMathews wants to merge 22 commits into
mainfrom
claude/fix-livequery-loading-status-01TNsEPERmfs3ub3e9iDRAzK

Conversation

@KyleAMathews

Copy link
Copy Markdown
Collaborator

For live queries using on-demand sync mode, the collection was being marked as ready immediately when source collections were ready, even though the initial loadSubset hadn't completed yet. This meant isLoading was false while data was still being fetched.

This fix ensures that:

  1. Live queries with on-demand sources track the initial loadSubset promise and show isLoading: true until it completes
  2. The collection status remains loading until the first data load finishes
  3. Subsequent loadSubset calls (pagination/windowing) do NOT affect the ready status - only the first load matters

Changes:

  • Add hasMarkedReady and hasSetupLoadingListener flags to track initial ready state in CollectionConfigBuilder
  • Modify updateLiveQueryStatus() to wait for first loadSubset to complete before calling markReady()
  • Update subscribeToMatchingChanges() in CollectionSubscriber to track the initial loadSubset promise for on-demand sources
  • Add comprehensive tests for the new behavior

🎯 Changes

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Loading
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@KyleAMathews@samwillis@kevin-dp@claude