diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 90211d07..98aa9782 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -19,6 +19,7 @@ 🐞 Fixed - [[#659]](https://github.com/GetStream/stream-chat-flutter/issues/659) Fixed unread count not updating correctly. +- Fix `Filter.empty()` json encoding. ## 2.2.1 diff --git a/packages/stream_chat/lib/src/core/models/filter.dart b/packages/stream_chat/lib/src/core/models/filter.dart index d4536eab..ca494bdb 100644 --- a/packages/stream_chat/lib/src/core/models/filter.dart +++ b/packages/stream_chat/lib/src/core/models/filter.dart @@ -102,6 +102,12 @@ class Filter extends Equatable { this.key, }) : operator = operator.rawValue; + /// An empty filter + const Filter.empty() + : value = const {}, + operator = null, + key = null; + /// Combines the provided filters and matches the values /// matched by all filters. factory Filter.and(List filters) => @@ -172,9 +178,6 @@ class Filter extends Equatable { String? key, }) = Filter.__; - /// An empty filter - factory Filter.empty() => const Filter.raw(value: {}); - /// Creates a custom [Filter] from a raw map value /// /// ```dart diff --git a/packages/stream_chat/test/src/core/models/filter_test.dart b/packages/stream_chat/test/src/core/models/filter_test.dart index 6e3dbf64..e396c2b3 100644 --- a/packages/stream_chat/test/src/core/models/filter_test.dart +++ b/packages/stream_chat/test/src/core/models/filter_test.dart @@ -139,7 +139,7 @@ void main() { }); test('empty', () { - final filter = Filter.empty(); + const filter = Filter.empty(); expect(filter.value, {}); }); @@ -226,6 +226,12 @@ void main() { json.encode(value), ); }); + + test('empty', () { + const filter = Filter.empty(); + final encoded = json.encode(filter); + expect(encoded, '{}'); + }); }); test('groupedFilter', () { diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index ed8f5e06..b2ef50cb 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -11,6 +11,13 @@ pagination = const PaginationParams(limit: 30) ``` +🔄 Changed + +- `UserListViewCore` filter property now has a default value. + ```dart + filter = const Filter.empty() + ``` + 🐞 Fixed - Fixed `MessageSearchListView` pagination. diff --git a/packages/stream_chat_flutter/lib/src/user_list_view.dart b/packages/stream_chat_flutter/lib/src/user_list_view.dart index 4d650192..12dbb3ec 100644 --- a/packages/stream_chat_flutter/lib/src/user_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/user_list_view.dart @@ -48,7 +48,7 @@ class UserListView extends StatefulWidget { /// Instantiate a new UserListView const UserListView({ Key? key, - this.filter, + this.filter = const Filter.empty(), this.sort, this.presence, this.pagination = const PaginationParams(limit: 30), @@ -76,6 +76,7 @@ class UserListView extends StatefulWidget { /// The query filters to use. /// You can query on any of the custom fields you've defined on the [Channel]. /// You can also filter other built-in channel fields. + // TODO: Make it non-nullable in a future breaking release final Filter? filter; /// The sorting used for the channels matching the filters. diff --git a/packages/stream_chat_flutter_core/CHANGELOG.md b/packages/stream_chat_flutter_core/CHANGELOG.md index f5da89c3..5ce1eb8b 100644 --- a/packages/stream_chat_flutter_core/CHANGELOG.md +++ b/packages/stream_chat_flutter_core/CHANGELOG.md @@ -11,10 +11,18 @@ pagination = const PaginationParams(limit: 30) ``` +🔄 Changed + +- `UserListViewCore` filter property now has a default value. + ```dart + filter = const Filter.empty() + ``` + 🐞 Fixed - Fixed `MessageSearchBloc` pagination. -- [[#673]](https://github.com/GetStream/stream-chat-flutter/issues/673): Fix `Core Widgets` not getting rebuild with new data on configuration change. +- [[#673]](https://github.com/GetStream/stream-chat-flutter/issues/673): Fix `Core Widgets` not getting rebuild with new + data on configuration change. ## 2.2.1 diff --git a/packages/stream_chat_flutter_core/lib/src/user_list_core.dart b/packages/stream_chat_flutter_core/lib/src/user_list_core.dart index 06ad7d80..75fc7411 100644 --- a/packages/stream_chat_flutter_core/lib/src/user_list_core.dart +++ b/packages/stream_chat_flutter_core/lib/src/user_list_core.dart @@ -63,7 +63,7 @@ class UserListCore extends StatefulWidget { required this.loadingBuilder, required this.listBuilder, Key? key, - this.filter, + this.filter = const Filter.empty(), this.sort, this.presence, this.pagination = const PaginationParams(limit: 30), @@ -91,6 +91,7 @@ class UserListCore extends StatefulWidget { /// The query filters to use. /// You can query on any of the custom fields you've defined on the [Channel]. /// You can also filter other built-in channel fields. + // TODO: Make it non-nullable in a future breaking release final Filter? filter; /// The sorting used for the channels matching the filters.