Skip to content

Conversation

@xsahil03x
Copy link
Member

Submit a pull request

Closes: FLU-305
Requires: GetStream/stream-core-flutter#16

Description of the pull request

This PR refactors FilterField and SortField from extension type to class to enable local, client-side filtering and sorting capabilities.

Key changes:

  • FilterField and SortField in all query files are now classes that hold both a remote string value for the API and a local value accessor function.
  • QueryConfiguration is now generic over the data type T (QueryConfiguration<T>) instead of separate Sort and FilterField types.
  • Typedefs for filters (e.g., ActivitiesFilter = Filter<ActivityData>) have been added for clarity.
  • FeedData.fid has been renamed to FeedData.feed for consistency.
  • Updated various state holders and doc snippets to align with the new generic query and field structures.

This commit refactors `FilterField` and `SortField` from `extension type` to `class` to enable local, client-side filtering and sorting capabilities.

Key changes:
- `FilterField` and `SortField` in all query files are now classes that hold both a remote string value for the API and a local value accessor function.
- `QueryConfiguration` is now generic over the data type `T` (`QueryConfiguration<T>`) instead of separate `Sort` and `FilterField` types.
- Typedefs for filters (e.g., `ActivitiesFilter = Filter<ActivityData>`) have been added for clarity.
- `FeedData.fid` has been renamed to `FeedData.feed` for consistency.
- Updated various state holders and doc snippets to align with the new generic query and field structures.
Pass the `query` object to all `EventHandler` instances instead of individual properties like `fid`.

This allows event handlers to access the query's filter conditions. When a real-time "updated" event is received, the handler now checks if the updated item still matches the filter. If it no longer matches, the item is removed from the local state, ensuring the UI stays consistent with the query's criteria.
@xsahil03x xsahil03x requested a review from a team as a code owner October 27, 2025 18:21
This commit updates the `stream_core` dependency from `^0.2.0` to `^0.3.0` in both `melos.yaml` and `packages/stream_feeds/pubspec.yaml`.
@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

❌ Patch coverage is 49.87406% with 199 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.86%. Comparing base (1926638) to head (3831fce).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../stream_feeds/lib/src/state/query/feeds_query.dart 12.82% 34 Missing ⚠️
...ream_feeds/lib/src/state/query/comments_query.dart 14.70% 29 Missing ⚠️
.../stream_feeds/lib/src/state/query/polls_query.dart 17.85% 23 Missing ⚠️
...am_feeds/lib/src/state/query/activities_query.dart 31.81% 15 Missing ⚠️
...am_feeds/lib/src/state/query/poll_votes_query.dart 25.00% 15 Missing ⚠️
...tream_feeds/lib/src/state/query/members_query.dart 6.66% 14 Missing ⚠️
.../lib/src/state/query/moderation_configs_query.dart 0.00% 13 Missing ⚠️
...ds/lib/src/state/query/bookmark_folders_query.dart 33.33% 10 Missing ⚠️
.../lib/src/state/query/activity_reactions_query.dart 0.00% 9 Missing ⚠️
...eam_feeds/lib/src/state/query/bookmarks_query.dart 35.71% 9 Missing ⚠️
... and 8 more

❌ Your patch status has failed because the patch coverage (49.87%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##             main      #51       +/-   ##
===========================================
+ Coverage   20.88%   40.86%   +19.97%     
===========================================
  Files         120      120               
  Lines        3289     3617      +328     
===========================================
+ Hits          687     1478      +791     
+ Misses       2602     2139      -463     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xsahil03x xsahil03x changed the title feat(llc): refactor FilterField and SortField to support local filtering refactor(llc): refactor FilterField and SortField to support local filtering Oct 28, 2025
This commit refactors the test suite to use the abstract `StreamFeedsClient` class instead of the concrete `StreamFeedsClientImpl` implementation.

This change improves test isolation by programming against the public API contract rather than the internal implementation details.

Key changes:
- Updated all test files to instantiate and reference `StreamFeedsClient`.
- Removed direct imports of `feeds_client_impl.dart` from the test suite.
- Removed the unnecessary Flutter SDK dependency from `pubspec.yaml`.
- Exposed `WebSocketProvider` and `DefaultApi` as `@visibleForTesting` parameters in the `StreamFeedsClient` factory constructor to facilitate mocking.
Comment on lines +164 to +165
@visibleForTesting WebSocketProvider? wsProvider,
@visibleForTesting api.DefaultApi? feedsRestApi,
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the reason you added these to the public interface? By using StreamFeedsClientImpl in the tests we don't really need that.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we should test internal implementation. We should only test the public API's

@xsahil03x xsahil03x merged commit 11b075c into main Oct 30, 2025
7 of 8 checks passed
@xsahil03x xsahil03x deleted the feat/local-filtering branch October 30, 2025 14:09
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.

3 participants