Skip to content

fix(ui_firestore): keep loaded pages while the next page is only in cache - #709

Merged
russellwheatley merged 5 commits into
mainfrom
fix/firestore-partial-cache-page
Sep 25, 2026
Merged

russellwheatley merged 5 commits into
mainfrom
fix/firestore-partial-cache-page

Conversation

@demolaf

@demolaf demolaf commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Fixes #238.

Stops FirestoreQueryBuilder from rendering a partial cache snapshot while fetching the next page, which shrank the list, set hasMore to false and reset the scroll position on web.

Changes

  • While a next page loads, ignore cache-only snapshots that drop more than one doc from the screen until the server responds. Snapshots that don't shrink the list, or drop one doc as a local delete does, render as before, so offline pagination still reaches the end.
  • Listen with metadata changes while waiting, so a server result identical to the cache still ends the fetch. Metadata-only events are still not rendered unless includeMetadataChanges is set.
  • Clear both isFetching and isFetchingMore on every event and error, so a query change mid-fetch no longer leaves fetchMore stuck.
  • Add widget tests for each case.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request upgrades the google_sign_in dependency to version 7.1.0 across packages and updates the Google authentication provider and buttons to support the new API, including adding support for serverClientId and handling separate authentication and authorization steps. Additionally, it improves FirestoreQueryBuilder to prevent list shrinking and scroll resetting by keeping current pages until the server responds when a new listener emits from the local cache. Feedback suggests wrapping the initialization and sign-out process in a try-catch block to prevent potential exceptions from blocking the main logout flow.

Comment thread packages/firebase_ui_oauth_google/lib/src/provider.dart
@demolaf
demolaf force-pushed the fix/firestore-partial-cache-page branch from 0641025 to 4764095 Compare September 23, 2026 12:45
@demolaf

demolaf commented Sep 23, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves the FirestoreQueryBuilder in firebase_ui_firestore to prevent list shrinking and scroll position resets when fetching subsequent pages. It retains current documents until the server responds or the user writes locally, ignoring smaller cached results while waiting for the server. It also optimizes the handling of metadata-only events and simplifies state updates on errors. Additionally, comprehensive widget tests have been added to verify these behaviors, and mock classes in tests have been updated accordingly. There are no review comments, and I have no further feedback to provide.

@russellwheatley russellwheatley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing on the shrink check.

Comment thread packages/firebase_ui_firestore/lib/src/query_builder.dart Outdated
@russellwheatley
russellwheatley merged commit 2350605 into main Sep 25, 2026
26 checks passed
@russellwheatley
russellwheatley deleted the fix/firestore-partial-cache-page branch September 25, 2026 13:52
Sign up for free to 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.

🐛 FirestoreListView renders (incomplete) local cache before remote db result

2 participants