Skip to content

feat(llc, core, persistence): Add support for PredefinedFilters on QueryChannels#2709

Open
VelikovPetar wants to merge 19 commits into
masterfrom
feature/FLU-357_predefined_filters_v10
Open

feat(llc, core, persistence): Add support for PredefinedFilters on QueryChannels#2709
VelikovPetar wants to merge 19 commits into
masterfrom
feature/FLU-357_predefined_filters_v10

Conversation

@VelikovPetar

@VelikovPetar VelikovPetar commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Submit a pull request

Linear: FLU-357

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested (add some information if not applicable)

Description of the pull request

Adds support for server-defined predefined filters on queryChannels across the LLC, persistence, and core layers.

A predefined filter is a named filter/sort preset that lives on the server. The client sends predefined_filter (plus optional filter_values / sort_values to interpolate placeholders) instead of an inline filter, and the server echoes back the materialized filter and sort it applied.

stream_chat (LLC)

  • ChannelApi.queryChannels and StreamChatClient.queryChannels accept predefinedFilter, filterValues, sortValues.
  • New StreamChatClient.queryChannelsWithResult returns a QueryChannelsResult exposing both the live channels and the server-resolved PredefinedFilter (name + materialized filter + sort).
  • New PredefinedFilter model and predefined_filter field on QueryChannelsResponse.
  • SortOption<T>.fromJson added so sort specs can round-trip through persistence.
  • New ChatPersistenceClient hooks: getChannelStatesByPredefinedFilter and updateChannelQueriesByPredefinedFilter (default no-op so existing implementations keep compiling).

stream_chat_persistence

  • New channel_query_metadata table that stores the server-resolved filter + sort keyed by the predefined-filter query hash, so offline reads reconstruct the exact resolved spec the server applied.
  • New FilterConverter and ChannelStateSortOrderConverter Drift converters.
  • StreamChatPersistenceClient implements the new hooks; ChannelQueryDao gains updateChannelQueriesByPredefinedFilter and getChannelsAndSpecByPredefinedFilter.

stream_chat_flutter_core

  • StreamChannelListController accepts predefinedFilter, filterValues, sortValues. When set, they take precedence over filter / channelStateSort.
  • The controller tracks a _resolvedChannelStateSort that is overwritten with the server-resolved sort on every successful query, so event-driven inserts keep matching the server's ordering even when the caller only specifies a predefinedFilter.

Sample app

  • ChannelList now uses the stream_chat_flutter_sample_app predefined filter (interpolated with the current user_id) to demonstrate the flow end-to-end.

How to test

  • Run the sample app and confirm the channel list renders, paginates, and reacts to events as before.
  • Toggle offline (airplane mode) after an online query and reopen — channels for the predefined-filter query should be served from persistence, ordered using the server-resolved sort.

Test coverage

  • predefined_filter_test.dart — model.
  • predefined_filter_defaults_test.dart — fallback-sort selection.
  • client_test.dart — online/offline queryChannels paths and queryChannelsWithResult.
  • channel_api_test.dart — request payload assertions.
  • filter_converter_test.dart / sort_order_converter_test.dart — Drift converters.
  • channel_query_dao_test.dart — DAO read/write of cids + metadata.
  • stream_chat_persistence_client_test.dart — persistence client integration.
  • stream_channel_list_controller_test.dart — controller path including resolved-sort tracking.

Summary by CodeRabbit

  • New Features
    • Added support for server-side predefined channel query filters via predefinedFilter with filterValues/sortValues, including server-resolved filter/sort materialization.
    • Introduced queryChannelsWithResult (and the QueryChannelsResult return type) to provide both channels and the resolved predefined filter details.
    • Updated StreamChannelListController to accept predefined filters and automatically apply the resolved sort.
  • Deprecations
    • Deprecated channel-query persistence read/write methods in favor of unified query metadata save/read APIs.
  • Other
    • Enhanced online/offline querying with improved persistence and caching of resolved query parameters.

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f8adcd17-a866-4089-8cc8-41f7a20337b4

📥 Commits

Reviewing files that changed from the base of the PR and between 91dd341 and 63992b5.

📒 Files selected for processing (2)
  • packages/stream_chat/lib/src/client/client.dart
  • packages/stream_chat_persistence/lib/src/stream_chat_persistence_client.dart
💤 Files with no reviewable changes (1)
  • packages/stream_chat/lib/src/client/client.dart

📝 Walkthrough

Walkthrough

Adds predefined filter support across the SDK. A new PredefinedFilter model and QueryChannelsResult type are introduced. The ChannelApi and QueryChannelsResponse are extended with predefined filter fields. A new ChannelQueriesMetadata Drift table (schema version 1033) stores resolved filter/sort specs. ChatPersistenceClient gains queryChannelStates/saveChannelQueries methods, and StreamChatClient is refactored around a queryChannelsWithResult API. StreamChannelListController wires the new API, and the sample app is updated to use a predefined filter.

Changes

Predefined Filter Feature

Layer / File(s) Summary
PredefinedFilter model, QueryChannelsResult, and SortOption.fromJson
packages/stream_chat/lib/src/core/models/predefined_filter.dart, packages/stream_chat/lib/src/core/models/predefined_filter.g.dart, packages/stream_chat/lib/src/client/query_channels_result.dart, packages/stream_chat/lib/src/core/api/sort_order.dart, packages/stream_chat/lib/stream_chat.dart
PredefinedFilter JSON model with effectiveSort heuristic (selects lastMessageAt or lastUpdated desc based on filter structure); QueryChannelsResult immutable pair of channels and optional resolved spec; SortOption.fromJson factory for deserialization; both types exported from the library.
ChannelApi and QueryChannelsResponse extension
packages/stream_chat/lib/src/core/api/channel_api.dart, packages/stream_chat/lib/src/core/api/responses.dart, packages/stream_chat/lib/src/core/api/responses.g.dart
queryChannels signature extended with predefinedFilter, filterValues, sortValues; request payload encodes the three new fields when non-null; QueryChannelsResponse gains optional predefinedFilter field deserialized from predefined_filter JSON key.
ChatPersistenceClient new APIs, deprecations, and converters
packages/stream_chat/lib/src/db/chat_persistence_client.dart, packages/stream_chat_persistence/lib/src/converter/filter_converter.dart, packages/stream_chat_persistence/lib/src/converter/sort_order_converter.dart, packages/stream_chat_persistence/lib/src/converter/converter.dart
getChannelStates and updateChannelQueries deprecated; new queryChannelStates (returns QueryChannelsResponse) and saveChannelQueries added with predefined-filter routing; FilterConverter and ChannelStateSortOrderConverter added for SQL serialization.
ChannelQueriesMetadata table, DAO methods, and generated code
packages/stream_chat_persistence/lib/src/entity/channel_queries_metadata.dart, packages/stream_chat_persistence/lib/src/entity/entity.dart, packages/stream_chat_persistence/lib/src/dao/channel_query_dao.dart, packages/stream_chat_persistence/lib/src/dao/channel_query_dao.g.dart, packages/stream_chat_persistence/lib/src/db/drift_chat_database.dart, packages/stream_chat_persistence/lib/src/db/drift_chat_database.g.dart, packages/stream_chat_persistence/lib/src/dao/*.g.dart
New ChannelQueriesMetadata Drift table stores queryHash, filter, sort; schema version bumped to 1033; ChannelQueryDao gains updateChannelQueriesByPredefinedFilter (transactional upsert with optional cache clear) and getChannelsAndSpecByPredefinedFilter (parallel CID + metadata fetch); generated code updated; extraneous cross-table accessors removed from other generated DAOs.
StreamChatPersistenceClient queryChannelStates and saveChannelQueries
packages/stream_chat_persistence/lib/src/stream_chat_persistence_client.dart
Implements queryChannelStates with predefined-filter DAO resolution, pinnedAt-conditional membership preloading, envelope sorting, page slicing, and per-CID hydration; implements saveChannelQueries routing to predefined or standard DAO path; getChannelStates and updateChannelQueries delegated to new shared impls.
StreamChatClient predefined filter query flow
packages/stream_chat/lib/src/client/client.dart
Introduces _queryChannelsCache for in-flight coalescing; adds queryChannelsWithResult public API; refactors _queryChannelsImpl to emit offline then online QueryChannelsResult; expands queryChannels, queryChannelsOnline, queryChannelsOffline with predefined filter params; persists resolved filter/sort via saveChannelQueries.
StreamChannelListController wiring and sample app
packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart, sample_app/lib/widgets/channel_list.dart
Controller constructors gain predefinedFilter, filterValues, sortValues; doInitialLoad and loadMore call queryChannelsWithResult; _resolveSort updates _resolvedChannelStateSort from server response; sample app replaces explicit member filter with predefinedFilter.
Tests
packages/stream_chat/test/src/client/client_test.dart, packages/stream_chat/test/src/core/api/channel_api_test.dart, packages/stream_chat/test/src/core/models/predefined_filter_test.dart, packages/stream_chat_flutter_core/test/stream_channel_list_controller_test.dart, packages/stream_chat_persistence/test/src/converter/*, packages/stream_chat_persistence/test/src/dao/channel_query_dao_test.dart, packages/stream_chat_persistence/test/stream_chat_persistence_client_test.dart
Updated persistence-enabled client tests to use new API names; added predefined filter coverage for queryChannelsOnline, queryChannelsOffline, queryChannelsWithResult; added PredefinedFilter model and API response tests; added converter round-trip tests; added DAO predefined filter write/read and cache-clear tests; added persistence client queryChannelStates/saveChannelQueries mode tests; added StreamChannelListController test suite.

Xcode Scheme Pre-Action

Layer / File(s) Summary
Xcode scheme Flutter prepare pre-action
sample_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
Adds a PreActions block executing xcode_backend.sh prepare before the scheme build phase.

Sequence Diagram(s)

sequenceDiagram
  participant App as StreamChannelListController
  participant Client as StreamChatClient
  participant Persistence as StreamChatPersistenceClient
  participant API as ChannelApi

  rect rgba(100, 149, 237, 0.5)
    note over App,Persistence: Offline-first pass
    App->>Client: queryChannelsWithResult(predefinedFilter, filterValues, sortValues)
    Client->>Persistence: queryChannelStates(predefinedFilter, filterValues, sortValues)
    Persistence->>Persistence: getChannelsAndSpecByPredefinedFilter → (channels, filter, sort)
    Persistence-->>Client: QueryChannelsResponse (offline)
    Client-->>App: emit QueryChannelsResult (channels, predefinedFilter) if non-empty
  end

  rect rgba(60, 179, 113, 0.5)
    note over Client,API: Online fetch and persist
    Client->>API: queryChannels(predefinedFilter, filterValues, sortValues)
    API-->>Client: QueryChannelsResponse (resolved predefinedFilter, channels)
    Client->>Persistence: saveChannelQueries(cids, resolvedFilter, resolvedSort, predefinedFilter)
    Persistence->>Persistence: updateChannelQueriesByPredefinedFilter(name, cids, filter, sort)
    Client-->>App: emit QueryChannelsResult (channels, predefinedFilter)
    App->>App: _resolveSort(result) → update _resolvedChannelStateSort
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

  • GetStream/stream-chat-flutter#2664: Refactors channel-state querying in StreamChatPersistenceClient with the same envelope-based paging approach that this PR renames and expands for predefined filter support.
  • GetStream/stream-chat-flutter#2659: Modifies the same persistence-enabled queryChannels test cases in client_test.dart, updating mock timing and verification expectations.

🐇 A rabbit hops through filter fields,
Predefined presets the server yields,
ChannelQueries stored with hash and sort,
Offline-first, then online caught!
QueryChannelsResult arrives just right—
Hooray, the channels load with might! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 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 support for predefined filters on QueryChannels across multiple layers (llc, core, persistence).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/FLU-357_predefined_filters_v10

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.

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

⚠️ Database Entity Files Modified

The following database entity files have been modified in this PR:

packages/stream_chat_persistence/lib/src/entity/channel_queries_metadata.dart
packages/stream_chat_persistence/lib/src/entity/entity.dart

📝 Remember to:

  1. Update database version in db/drift_chat_database.dart.
  2. Update entity schema tests if necessary.

Note: This comment is automatically generated by the CI workflow.

/// Yields the offline-cached result first (when available), followed by
/// the online result. Concurrent identical online queries are coalesced
/// via [_queryChannelsCache].
Stream<QueryChannelsResult> queryChannelsWithResult({

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wasn't sure about the naming here, I tried to make it as explicit as possible. (it wasn't really possible to use the existing queryChannels without a breaking change, as we must change the return type).

/// Carries the live [Channel] instances matching the query alongside the
/// server-resolved [PredefinedFilter] spec (when one is associated with the
/// query).
class QueryChannelsResult {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I introduced this new model to serve as a container for the result of the StreamChatClient.queryChannelsWithResult.

Future<List<Channel>> queryChannelsOnline({
Filter? filter,
SortOrder<ChannelState>? sort,
String? predefinedFilter,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note: At the moment I didn't expose public queryChannelsWithResultOnline/queryChannelsWithResultOffline -> only the new queryChannelsWithResults is public. I didn't want to pollute the public API, with methods which most likely will not be used. Let me know if you think we should expose them as well.

Comment thread packages/stream_chat/lib/src/core/api/channel_api.dart
Comment thread packages/stream_chat/lib/src/core/util/predefined_filter_defaults.dart Outdated
/// Default implementation returns an empty response; persistence
/// implementations that support predefined-filter caching should override
/// this.
Future<QueryChannelsResponse> getChannelStatesByPredefinedFilter({

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do you think it is OK to return QueryChannelsResponse here - or should we introduce a new specific model for this?

@VelikovPetar VelikovPetar marked this pull request as ready for review June 2, 2026 18:04
@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.07317% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.75%. Comparing base (037ce8d) to head (626d48b).

Files with missing lines Patch % Lines
...tream_chat/lib/src/db/chat_persistence_client.dart 0.00% 6 Missing ⚠️
...r_core/lib/src/stream_channel_list_controller.dart 80.95% 4 Missing ⚠️
packages/stream_chat/lib/src/client/client.dart 94.11% 2 Missing ⚠️
...hat_persistence/lib/src/dao/channel_query_dao.dart 97.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2709      +/-   ##
==========================================
+ Coverage   68.42%   68.75%   +0.32%     
==========================================
  Files         413      417       +4     
  Lines       24944    25081     +137     
==========================================
+ Hits        17069    17244     +175     
+ Misses       7875     7837      -38     

☔ View full report in Codecov by Harness.
📢 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.

@VelikovPetar VelikovPetar requested a review from a team June 3, 2026 10:56
Base automatically changed from v10.0.0 to master June 9, 2026 10:25
# Conflicts:
#	packages/stream_chat_persistence/lib/src/db/drift_chat_database.dart
#	packages/stream_chat_persistence/lib/src/stream_chat_persistence_client.dart
Comment thread packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart Outdated
Comment thread packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart Outdated

void _resolveSort(QueryChannelsResult result) {
final resolved = result.predefinedFilter?.sort;
if (resolved != null) _resolvedChannelStateSort = resolved;

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.

Should we handle the null case here or always rely on the value returned from backend?

@VelikovPetar VelikovPetar Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, I only added the fallback sort when predefinedFilter.sort == null when persisting the sort in the DB. I will fix this, we should also apply the same fallback here (only when predefinedFilter != null && predefinedFilter.sort == null).

Edit: A bit more info, if we get a PredefinedFilter with null sort, it means that there is no sort template provided for that predefined filter. So the BE will use a fallback sorter, calculated as predefinedFilterFallbackSort

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed here: 784e39c

Note: I also refactored the fallbackSort calculation a bit, to avoid exposing the algorithm as a public API.

@xsahil03x xsahil03x Jun 15, 2026

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.

Edit: A bit more info, if we get a PredefinedFilter with null sort, it means that there is no sort template provided for that predefined filter. So the BE will use a fallback sorter, calculated as predefinedFilterFallbackSort

Not sure, but in case there's no sort template provided for the predefined filter, then the backend will use a fallback sorter, so shouldn't we also set it if we don't receive it in the result? Currently we are handling the case only when its not null.

Related: https://github.com/GetStream/stream-chat-flutter/pull/2709/changes#r3414280459

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
packages/stream_chat/CHANGELOG.md (1)

11-12: 💤 Low value

Changelog entries accurately document the predefined filter feature—consider explicitly naming the new QueryChannelsResult type.

The entries describe the queryChannels and queryChannelsWithResult API expansions and the new unified persistence methods clearly. However, the PR introduces a new QueryChannelsResult type that is not explicitly mentioned. While it may be implicit via queryChannelsWithResult, calling it out would improve clarity for developers consulting the changelog.

💡 Optional enhancement to Line 11
- Added support for predefined filters for `QueryChannels` on `StreamChatClient` (`StreamChatClient.queryChannels` and `StreamChatClient.queryChannelsWithResult`).
+ Added support for predefined filters for `QueryChannels` on `StreamChatClient` via `StreamChatClient.queryChannels` and `StreamChatClient.queryChannelsWithResult` (returns `QueryChannelsResult`).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/stream_chat/CHANGELOG.md` around lines 11 - 12, Update the
CHANGELOG.md entries at lines 11-12 to explicitly mention the new
QueryChannelsResult type that was introduced in this PR. While the current
entries describe the queryChannels and queryChannelsWithResult method
expansions, adding a specific reference to the QueryChannelsResult type will
make the changelog clearer for developers. Add an entry that clearly documents
the introduction of this new type alongside or near the existing entries about
the queryChannels API changes.
packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart (1)

203-233: ⚡ Quick win

Consider calling _resolveSort(result) in loadMore for consistency.

doInitialLoad calls _resolveSort(result) after each query response to keep _resolvedChannelStateSort synchronized with the server (line 184), but loadMore does not. If the server changes the resolved sort between initial load and pagination (unlikely but possible), the controller will use a stale sort for subsequent operations.

For correctness and consistency with doInitialLoad, add the same call here after line 217:

🔄 Suggested addition
       )) {
+        _resolveSort(result);
         final channels = result.channels;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart`
around lines 203 - 233, The loadMore method is missing a call to
_resolveSort(result) to keep _resolvedChannelStateSort synchronized with the
server, which is inconsistently different from the doInitialLoad method that
does call _resolveSort(result) after each query response. Add a call to
_resolveSort(result) inside the await for loop in loadMore after receiving the
result from client.queryChannelsWithResult to ensure the resolved sort is
updated consistently and prevents using stale sort values for subsequent
operations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/stream_chat_persistence/lib/src/stream_chat_persistence_client.dart`:
- Around line 428-453: The saveChannelQueries method is missing a required doc
comment on this public API. Add a doc comment above the method that documents
its purpose, explains all parameters, and clarifies when to use this method
versus the deprecated updateChannelQueries method to help developers understand
the API better.
- Around line 302-323: The queryChannelStates method is a public API that is
missing a required doc comment. Add a documentation comment above the method
(before the `@override` annotation) that explains what the method does, describes
each parameter (filter, sort, predefinedFilter, filterValues, sortValues,
messageLimit, paginationParams), and documents the Future<QueryChannelsResponse>
return value to meet the coding guidelines for public APIs.

---

Nitpick comments:
In
`@packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart`:
- Around line 203-233: The loadMore method is missing a call to
_resolveSort(result) to keep _resolvedChannelStateSort synchronized with the
server, which is inconsistently different from the doInitialLoad method that
does call _resolveSort(result) after each query response. Add a call to
_resolveSort(result) inside the await for loop in loadMore after receiving the
result from client.queryChannelsWithResult to ensure the resolved sort is
updated consistently and prevents using stale sort values for subsequent
operations.

In `@packages/stream_chat/CHANGELOG.md`:
- Around line 11-12: Update the CHANGELOG.md entries at lines 11-12 to
explicitly mention the new QueryChannelsResult type that was introduced in this
PR. While the current entries describe the queryChannels and
queryChannelsWithResult method expansions, adding a specific reference to the
QueryChannelsResult type will make the changelog clearer for developers. Add an
entry that clearly documents the introduction of this new type alongside or near
the existing entries about the queryChannels API changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d4f485b0-756d-4881-a34b-cdfc1d4ac3f9

📥 Commits

Reviewing files that changed from the base of the PR and between 5f5b23b and 784e39c.

📒 Files selected for processing (42)
  • packages/stream_chat/CHANGELOG.md
  • packages/stream_chat/lib/src/client/client.dart
  • packages/stream_chat/lib/src/client/query_channels_result.dart
  • packages/stream_chat/lib/src/core/api/channel_api.dart
  • packages/stream_chat/lib/src/core/api/responses.dart
  • packages/stream_chat/lib/src/core/api/responses.g.dart
  • packages/stream_chat/lib/src/core/api/sort_order.dart
  • packages/stream_chat/lib/src/core/models/predefined_filter.dart
  • packages/stream_chat/lib/src/core/models/predefined_filter.g.dart
  • packages/stream_chat/lib/src/db/chat_persistence_client.dart
  • packages/stream_chat/lib/stream_chat.dart
  • packages/stream_chat/test/src/client/client_test.dart
  • packages/stream_chat/test/src/core/api/channel_api_test.dart
  • packages/stream_chat/test/src/core/models/predefined_filter_test.dart
  • packages/stream_chat_flutter_core/CHANGELOG.md
  • packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart
  • packages/stream_chat_flutter_core/test/stream_channel_list_controller_test.dart
  • packages/stream_chat_persistence/CHANGELOG.md
  • packages/stream_chat_persistence/lib/src/converter/converter.dart
  • packages/stream_chat_persistence/lib/src/converter/filter_converter.dart
  • packages/stream_chat_persistence/lib/src/converter/sort_order_converter.dart
  • packages/stream_chat_persistence/lib/src/dao/channel_query_dao.dart
  • packages/stream_chat_persistence/lib/src/dao/channel_query_dao.g.dart
  • packages/stream_chat_persistence/lib/src/dao/draft_message_dao.g.dart
  • packages/stream_chat_persistence/lib/src/dao/location_dao.g.dart
  • packages/stream_chat_persistence/lib/src/dao/member_dao.g.dart
  • packages/stream_chat_persistence/lib/src/dao/message_dao.g.dart
  • packages/stream_chat_persistence/lib/src/dao/pinned_message_reaction_dao.g.dart
  • packages/stream_chat_persistence/lib/src/dao/poll_vote_dao.g.dart
  • packages/stream_chat_persistence/lib/src/dao/reaction_dao.g.dart
  • packages/stream_chat_persistence/lib/src/dao/read_dao.g.dart
  • packages/stream_chat_persistence/lib/src/db/drift_chat_database.dart
  • packages/stream_chat_persistence/lib/src/db/drift_chat_database.g.dart
  • packages/stream_chat_persistence/lib/src/entity/channel_queries_metadata.dart
  • packages/stream_chat_persistence/lib/src/entity/entity.dart
  • packages/stream_chat_persistence/lib/src/stream_chat_persistence_client.dart
  • packages/stream_chat_persistence/test/src/converter/filter_converter_test.dart
  • packages/stream_chat_persistence/test/src/converter/sort_order_converter_test.dart
  • packages/stream_chat_persistence/test/src/dao/channel_query_dao_test.dart
  • packages/stream_chat_persistence/test/stream_chat_persistence_client_test.dart
  • sample_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
  • sample_app/lib/widgets/channel_list.dart
💤 Files with no reviewable changes (7)
  • packages/stream_chat_persistence/lib/src/dao/member_dao.g.dart
  • packages/stream_chat_persistence/lib/src/dao/message_dao.g.dart
  • packages/stream_chat_persistence/lib/src/dao/location_dao.g.dart
  • packages/stream_chat_persistence/lib/src/dao/reaction_dao.g.dart
  • packages/stream_chat_persistence/lib/src/dao/read_dao.g.dart
  • packages/stream_chat_persistence/lib/src/dao/pinned_message_reaction_dao.g.dart
  • packages/stream_chat_persistence/lib/src/dao/poll_vote_dao.g.dart

Comment thread packages/stream_chat_persistence/lib/src/stream_chat_persistence_client.dart Outdated
Comment thread packages/stream_chat_persistence/lib/src/stream_chat_persistence_client.dart Outdated
Comment thread packages/stream_chat/lib/src/client/client.dart Outdated
Comment thread packages/stream_chat/lib/src/core/models/predefined_filter.dart Outdated
Comment thread packages/stream_chat/lib/src/client/client.dart Outdated
const defaultChannelPagedLimit = 10;

/// The default sort used for the channel list.
const defaultChannelListSort = [

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.

I think we also need to update this and have the default one based on if we are passing predefined filters or not. wdyt?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Let me check how we can improve this. In the predefined filters case, we need to already have the QueryChannels response, so that we can derive the default sort based on the filter fields (if sort is not already returned by the response)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What do you think about something like:

 StreamChannelListController({
    required this.client,
    StreamChannelListEventHandler? eventHandler,
    this.filter,                                                                                                                                                                   
    this.predefinedFilter,                         
    this.filterValues,                                                                                                                                                             
    this.sortValues,                                                                                                                                                             
    this.presence = true,
    this.limit = defaultChannelPagedLimit,                                                                                                                                         
    this.messageLimit,                    
    this.memberLimit,                                                                                                                                                              
  }) : _eventHandler = eventHandler ?? StreamChannelListEventHandler(),                                                                                                          
       _resolvedChannelStateSort =                                     
           predefinedFilter == null ? channelStateSort : null,                                                                                                                     
       super(const PagedValue.loading());                     

I was also considering something like:

StreamChannelListController({                                                                                                                                                    
    required this.client,
    StreamChannelListEventHandler? eventHandler,                                                                                                                                   
    this.filter,                                                                                                                                                                 
    SortOrder<ChannelState>? channelStateSort,   // ← no inline default, nullable named param
    this.predefinedFilter,
    this.filterValues,
    this.sortValues,
    this.presence = true,
    this.limit = defaultChannelPagedLimit,
    this.messageLimit,
    this.memberLimit,
  }) : channelStateSort = channelStateSort ??
           (predefinedFilter == null ? defaultChannelListSort : null),
       _resolvedChannelStateSort = channelStateSort ??
           (predefinedFilter == null ? defaultChannelListSort : null),
       _eventHandler = eventHandler ?? StreamChannelListEventHandler(),
       super(const PagedValue.loading());

However this could be a breaking change, if a customer is instantiating the StreamChannelListController as:

StreamChannelListController(
    client: client,
    channelStateSort: null,   // explicit "I don't want a sort"
  )

In which case they will now fallback to the defaultChannelListSort, instead of the explicit null.

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.

2 participants