Skip to content

Added SheetId filter to the content list providers#188

Merged
kumarpalsinh25 merged 8 commits intomainfrom
kumar/list-filter-changes
Dec 16, 2025
Merged

Added SheetId filter to the content list providers#188
kumarpalsinh25 merged 8 commits intomainfrom
kumar/list-filter-changes

Conversation

@kumarpalsinh25
Copy link
Copy Markdown
Collaborator

@kumarpalsinh25 kumarpalsinh25 commented Dec 16, 2025

Summary by CodeRabbit

  • New Features

    • Sheet-based filtering enabled across bullets, events, lists, polls, tasks, and text so views show only selected-sheet data.
    • Added a provider exposing the current list of sheet IDs for reuse.
    • Improved where-in filtering to handle large sets of sheet IDs reliably and added a sheetId field constant.
  • Chores

    • Streamlined subscription and disposal logic for filtered data listeners.

✏️ Tip: You can customize this high-level summary in your review settings.

Introduced a `listOfSheetIdsProvider` to get a list of sheet IDs the current user can access.

Updated the data providers for tasks, polls, and events to use this list, filtering their Firestore queries to only fetch documents related to these specific sheets. This optimizes data fetching by ensuring only relevant information is streamed to the client.
Modified the `allTextProvider` and `allBulletsProvider` to fetch data more efficiently. The providers now use `listOfSheetIdsProvider` to filter Firestore queries, ensuring that only texts and bullets belonging to the user's accessible sheets are retrieved. This change optimizes data loading by reducing the amount of data fetched from the database.
Modified the `listStreamProvider` to filter lists based on a list of sheet IDs obtained from `listOfSheetIdsProvider`. This ensures that only lists associated with the specified sheets are fetched and listened to.
Conditionally apply the `whereIn` filter for `sheetId` only when the `sheetIds` list is not empty. This prevents a Firestore error that occurs when an empty list is passed to a `whereIn` query.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 16, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a new Riverpod provider exposing sheet ID lists and updates multiple feature providers to build Firestore queries that conditionally apply a whereIn filter on sheetId using that provider; also adds a Firestore whereIn batching utility and updates generated provider hash literals.

Changes

Cohort / File(s) Summary
Core Sheet Provider
lib/features/sheet/providers/sheet_providers.dart
Adds listOfSheetIds(Ref ref) returning a List<String> of sheet IDs derived from sheetListProvider.
Generated Sheet Provider
lib/features/sheet/providers/sheet_providers.g.dart
Adds listOfSheetIdsProvider scaffolding (const provider, provider class, create/overrideWithValue, and hash function).
Feature providers using sheet IDs
lib/features/bullets/providers/bullet_providers.dart, lib/features/events/providers/event_providers.dart, lib/features/list/providers/list_providers.dart, lib/features/polls/providers/poll_providers.dart, lib/features/task/providers/task_providers.dart, lib/features/text/providers/text_providers.dart
Each imports sheet_providers.dart, watches listOfSheetIdsProvider, builds a Firestore Query and conditionally applies a whereIn on FirestoreFieldConstants.sheetId when the ID list is non-empty; listeners now subscribe to query.snapshots() and disposals cancel subscriptions.
Updated generated provider hashes
lib/features/*/providers/*_providers.g.dart (e.g., .../bullet_providers.g.dart, .../event_providers.g.dart, .../list_providers.g.dart, .../poll_providers.g.dart, .../task_providers.g.dart, .../text_providers.g.dart)
Only the auto-generated create-source hash string literals changed; no runtime logic or public signatures altered.
Firestore utility
lib/common/utils/firebase_utils.dart
Adds whereInFilter(String field, List<Object?> values) to safely build Firestore whereIn filters by batching lists into 30-item chunks and OR-combining batch filters for large lists.
Constants
lib/constants/firestore_field_constants.dart
Adds sheetId = 'sheetId' constant.

Sequence Diagram(s)

sequenceDiagram
    participant UI as UI (Consumer)
    participant RP as Riverpod Provider
    participant QB as Query Builder (local)
    participant FS as Firestore
    UI->>RP: subscribe to feature provider
    RP->>RP: ref.watch(listOfSheetIdsProvider) -> sheetIds
    RP->>QB: build Query (collection + conditional whereIn with sheetIds)
    QB->>FS: query.snapshots()
    FS-->>RP: snapshot stream (documents)
    RP->>RP: map docs -> models, update state
    RP-->>UI: emit new state
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Review focus:
    • Correct behavior when listOfSheetIds is empty (no whereIn applied).
    • Correct batching and OR-composition in whereInFilter (edge cases around batch counts).
    • Subscription lifecycle and cancellation on dispose.
    • Ensure generated .g.dart hash changes are mechanical.

Possibly related PRs

Suggested reviewers

  • anisha-e10

Poem

🐇 I nibble IDs from each sheet’s stack,

I stitch queries so no doc will lack.
Streams hop in with stories to tell,
Batched filters hum — all queries well. ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately describes the main change: adding SheetId filtering to content list providers across multiple features.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a763314 and 0fba822.

📒 Files selected for processing (2)
  • lib/common/utils/firebase_utils.dart (1 hunks)
  • lib/constants/firestore_field_constants.dart (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

This commit updates the auto-generated provider hash values across various feature modules, including text, list, task, polls, bullets, and events.
@kumarpalsinh25 kumarpalsinh25 marked this pull request as ready for review December 16, 2025 10:44
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 00a45b1 and 7597e2f.

⛔ Files ignored due to path filters (1)
  • ios/Podfile.lock is excluded by !**/*.lock
📒 Files selected for processing (14)
  • lib/features/bullets/providers/bullet_providers.dart (2 hunks)
  • lib/features/bullets/providers/bullet_providers.g.dart (1 hunks)
  • lib/features/events/providers/event_providers.dart (3 hunks)
  • lib/features/events/providers/event_providers.g.dart (1 hunks)
  • lib/features/list/providers/list_providers.dart (2 hunks)
  • lib/features/list/providers/list_providers.g.dart (1 hunks)
  • lib/features/polls/providers/poll_providers.dart (3 hunks)
  • lib/features/polls/providers/poll_providers.g.dart (1 hunks)
  • lib/features/sheet/providers/sheet_providers.dart (1 hunks)
  • lib/features/sheet/providers/sheet_providers.g.dart (1 hunks)
  • lib/features/task/providers/task_providers.dart (2 hunks)
  • lib/features/task/providers/task_providers.g.dart (1 hunks)
  • lib/features/text/providers/text_providers.dart (2 hunks)
  • lib/features/text/providers/text_providers.g.dart (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: linux
  • GitHub Check: ios
  • GitHub Check: windows
  • GitHub Check: test
  • GitHub Check: android
  • GitHub Check: macos
  • GitHub Check: Test zoe_native plugin
🔇 Additional comments (18)
lib/features/events/providers/event_providers.g.dart (1)

47-47: LGTM - Generated hash update reflects source changes.

The updated hash value is auto-generated by Riverpod's code generator to reflect changes in the source event_providers.dart file.

lib/features/text/providers/text_providers.g.dart (1)

44-44: LGTM - Generated hash update.

Auto-generated hash reflecting source changes in text_providers.dart.

lib/features/polls/providers/poll_providers.g.dart (1)

44-44: LGTM - Generated hash update.

Auto-generated hash reflecting source changes in poll_providers.dart.

lib/features/bullets/providers/bullet_providers.g.dart (1)

47-47: LGTM - Generated hash update.

Auto-generated hash reflecting source changes in bullet_providers.dart.

lib/features/sheet/providers/sheet_providers.g.dart (1)

202-246: LGTM - New generated provider for sheet ID filtering.

The generated ListOfSheetIdsProvider follows the standard Riverpod 3.0 patterns correctly:

  • Proper functional provider structure with $FunctionalProvider mixin
  • Auto-dispose enabled (appropriate for derived data)
  • Standard overrideWithValue support for testing
  • Hash function for debugging

This provider enables the sheet-based filtering feature across other providers (bullets, events, lists, polls, tasks, texts).

lib/features/task/providers/task_providers.dart (1)

10-10: LGTM: Import added for sheet filtering.

The import of sheet_providers.dart is necessary to access listOfSheetIdsProvider for the new filtering functionality.

lib/features/text/providers/text_providers.dart (2)

9-9: LGTM: Import added for sheet filtering.


28-36: Sheet-based filtering implemented consistently.

The filtering logic matches the pattern used in other providers. Note that the Firestore whereIn limit of 10 values (flagged in task_providers.dart) applies here as well.

lib/features/list/providers/list_providers.dart (2)

11-11: LGTM: Import added for sheet filtering.


28-36: Sheet-based filtering implemented consistently.

The filtering logic matches the pattern used in other providers. The Firestore whereIn limit concern flagged in task_providers.dart applies here as well.

lib/features/polls/providers/poll_providers.dart (2)

11-11: LGTM: Import added for sheet filtering.


30-50: Sheet-based filtering implemented consistently with disposal cleanup.

The filtering logic matches the pattern used in other providers, and the disposal callback has been appropriately simplified to an arrow function. The Firestore whereIn limit concern flagged in task_providers.dart applies here as well.

lib/features/bullets/providers/bullet_providers.dart (2)

9-9: LGTM: Import added for sheet filtering.


29-37: Sheet-based filtering implemented consistently.

The filtering logic matches the pattern used in other providers. The Firestore whereIn limit concern flagged in task_providers.dart applies here as well.

lib/features/sheet/providers/sheet_providers.dart (1)

200-204: LGTM: New provider for sheet ID filtering.

The listOfSheetIds provider cleanly exposes the list of sheet IDs from the sheetListProvider. This is consumed by other feature providers to filter their Firestore queries.

However, note that this provider's values are used with Firestore's whereIn operator (as seen in task_providers.dart, text_providers.dart, etc.), which has a hard limit of 10 values. If users can have more than 10 sheets, the filtering queries will fail at runtime. Please verify whether the application design constrains the sheet count to 10 or fewer, or implement query pagination/chunking if higher counts are expected.

lib/features/events/providers/event_providers.dart (3)

12-12: LGTM!

The import is necessary for accessing listOfSheetIdsProvider used in the sheet filtering logic below.


38-38: LGTM!

The change from collection.snapshots() to query.snapshots() correctly applies the conditional sheet-based filtering while preserving the existing snapshot handling logic.


50-50: LGTM!

The simplified arrow function syntax is more concise while maintaining the same cleanup behavior.

Comment thread lib/features/events/providers/event_providers.dart
Comment thread lib/features/task/providers/task_providers.dart
Replaced the direct use of `Filter` with the `whereInFilter` helper function across multiple feature providers (`text`, `list`, `task`, `polls`, `events`, `bullets`) to standardize and simplify Firestore query construction for `whereIn` clauses.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (1)
lib/features/task/providers/task_providers.dart (1)

30-38: Verify that whereInFilter handles Firestore's 30-item limit.

The filtering logic correctly conditionally applies the whereIn filter when sheet IDs are present. However, as flagged in a previous review, Firestore's whereIn operator has a maximum of 30 equality clauses.

Please verify whether the whereInFilter helper function (from firebase_utils.dart) already implements chunking for lists exceeding 30 items:

#!/bin/bash
# Check if whereInFilter already implements chunking logic
echo "=== Searching for whereInFilter implementation ==="
rg -n "whereInFilter" --type=dart -A 20 -B 2

echo -e "\n=== Checking for any existing chunking patterns in firebase_utils ==="
rg -n "chunk|batch.*30|whereIn.*30" --type=dart lib/common/utils/firebase_utils.dart -A 5 -B 2

If whereInFilter does not handle chunking, the previous review comment's suggested implementation should be applied to prevent runtime failures when users accumulate more than 30 sheets.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7597e2f and c7e754c.

📒 Files selected for processing (6)
  • lib/features/bullets/providers/bullet_providers.dart (2 hunks)
  • lib/features/events/providers/event_providers.dart (3 hunks)
  • lib/features/list/providers/list_providers.dart (2 hunks)
  • lib/features/polls/providers/poll_providers.dart (3 hunks)
  • lib/features/task/providers/task_providers.dart (2 hunks)
  • lib/features/text/providers/text_providers.dart (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • lib/features/list/providers/list_providers.dart
  • lib/features/events/providers/event_providers.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: ios
  • GitHub Check: macos
  • GitHub Check: test
  • GitHub Check: android
  • GitHub Check: windows
  • GitHub Check: Test zoe_native plugin
  • GitHub Check: format
  • GitHub Check: linux
🔇 Additional comments (6)
lib/features/task/providers/task_providers.dart (1)

10-10: LGTM!

The import is necessary for accessing listOfSheetIdsProvider and is correctly added.

lib/features/bullets/providers/bullet_providers.dart (2)

9-9: LGTM!

The import is necessary for the listOfSheetIdsProvider used in the build method.


37-37: LGTM!

The subscription correctly uses the filtered query, and the reactive dependency on listOfSheetIdsProvider will properly rebuild the subscription when sheet IDs change. The subscription cleanup is also handled correctly.

lib/features/polls/providers/poll_providers.dart (3)

11-11: LGTM! Import is necessary for the new sheet ID filtering.

The import of sheet_providers is required to access listOfSheetIdsProvider for the dynamic filtering functionality.


38-38: LGTM! Query usage is correct.

The change from _collection.snapshots() to query.snapshots() properly applies the conditional filter built in the preceding lines.


50-50: LGTM! Cleaner disposal syntax.

The arrow function syntax is more concise while maintaining the same functionality for canceling the subscription on disposal.

Comment thread lib/features/bullets/providers/bullet_providers.dart
Comment thread lib/features/polls/providers/poll_providers.dart
Comment thread lib/features/text/providers/text_providers.dart
Introduces `whereInFilter`, a utility function to create Firestore-safe `whereIn` queries for lists of any size.

This function handles Firestore's limit of 30 values for a `whereIn` clause by automatically splitting larger lists into multiple `Filter.or` conditions.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
lib/common/utils/firebase_utils.dart (2)

51-52: Consider throwing an exception instead of using assert for input validation.

The assert statement only runs in debug mode. In release builds, passing an empty list will cause Filter(field, whereIn: []) to be created, which may lead to unexpected Firestore behavior or errors.

 Filter whereInFilter(String field, List<Object?> values) {
-  assert(values.isNotEmpty, 'values must not be empty');
+  if (values.isEmpty) {
+    throw ArgumentError('values must not be empty');
+  }

65-67: Minor: Simplify sublist bounds using min.

+import 'dart:math' show min;
+
 // In the loop:
-        whereIn: values.sublist(
-          i,
-          i + _whereInLimit > values.length ? values.length : i + _whereInLimit,
-        ),
+        whereIn: values.sublist(i, min(i + _whereInLimit, values.length)),
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c7e754c and a763314.

📒 Files selected for processing (1)
  • lib/common/utils/firebase_utils.dart (1 hunks)

Comment thread lib/common/utils/firebase_utils.dart
…nstant

The 'and' filter for combining Firestore queries has been corrected to 'or' to ensure proper query logic. Additionally, a 'sheetId' constant has been added to the Firestore field constants.
@kumarpalsinh25 kumarpalsinh25 merged commit 710728f into main Dec 16, 2025
6 of 9 checks passed
@kumarpalsinh25 kumarpalsinh25 deleted the kumar/list-filter-changes branch December 16, 2025 11:41
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.

1 participant