From a931682b4c3551580eb5d08b356afb235dbad37d Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 27 Sep 2021 17:46:57 +0530 Subject: [PATCH 1/8] added not exists filter --- .../stream_chat/lib/src/core/models/filter.dart | 15 +++++++++++---- .../test/src/core/models/filter_test.dart | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/stream_chat/lib/src/core/models/filter.dart b/packages/stream_chat/lib/src/core/models/filter.dart index ca494bdb..ba7d044e 100644 --- a/packages/stream_chat/lib/src/core/models/filter.dart +++ b/packages/stream_chat/lib/src/core/models/filter.dart @@ -40,9 +40,12 @@ enum FilterOperator { /// Matches values with the specified prefix. autoComplete, - /// Matches values that exist/don't exist based on the specified boolean value. + /// Matches values that exist. exists, + /// Matches values that don't exist. + notExists, + /// Matches all the values specified in an array. and, @@ -163,9 +166,13 @@ class Filter extends Equatable { factory Filter.autoComplete(String key, String text) => Filter._(operator: FilterOperator.autoComplete, key: key, value: text); - /// Matches values that exist/don't exist based on the specified boolean value. - factory Filter.exists(String key, {bool exists = true}) => - Filter._(operator: FilterOperator.exists, key: key, value: exists); + /// Matches values that exist. + factory Filter.exists(String key) => + Filter._(operator: FilterOperator.exists, key: key, value: true); + + /// Matches values that don't exist. + factory Filter.notExists(String key) => + Filter._(operator: FilterOperator.exists, key: key, value: false); /// Matches any list that contains the specified values factory Filter.contains(String key, Object value) => 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 c0a8ce8f..f836d845 100644 --- a/packages/stream_chat/test/src/core/models/filter_test.dart +++ b/packages/stream_chat/test/src/core/models/filter_test.dart @@ -114,7 +114,7 @@ void main() { test('notExists', () { const key = 'testKey'; - final filter = Filter.exists(key, exists: false); + final filter = Filter.notExists(key); expect(filter.key, key); expect(filter.value, isFalse); expect(filter.operator, FilterOperator.exists.rawValue); From d996eddb568e0b421a25e688a79325253cbb4fde Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 27 Sep 2021 17:59:59 +0530 Subject: [PATCH 2/8] added changelog --- packages/stream_chat/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 3c7dd84f..06370e64 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -1,3 +1,9 @@ +## Upcoming + +🛑️ Breaking Changes from `3.0.0` + +- `Filter.notExists` now replaces `Filter.exists(key, exists: false)`. + ## 3.0.0 🛑️ Breaking Changes from `2.2.1` From 98493b77d8bc4c3a30aea80cefb5ee8e2fa345b0 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 27 Sep 2021 18:37:26 +0530 Subject: [PATCH 3/8] removed breaking change --- packages/stream_chat/CHANGELOG.md | 2 +- packages/stream_chat/lib/src/core/models/filter.dart | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 06370e64..c12377b1 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -1,6 +1,6 @@ ## Upcoming -🛑️ Breaking Changes from `3.0.0` +✅ Added - `Filter.notExists` now replaces `Filter.exists(key, exists: false)`. diff --git a/packages/stream_chat/lib/src/core/models/filter.dart b/packages/stream_chat/lib/src/core/models/filter.dart index ba7d044e..fb4cfb42 100644 --- a/packages/stream_chat/lib/src/core/models/filter.dart +++ b/packages/stream_chat/lib/src/core/models/filter.dart @@ -167,12 +167,11 @@ class Filter extends Equatable { Filter._(operator: FilterOperator.autoComplete, key: key, value: text); /// Matches values that exist. - factory Filter.exists(String key) => - Filter._(operator: FilterOperator.exists, key: key, value: true); + factory Filter.exists(String key, {bool exists = true}) => + Filter._(operator: FilterOperator.exists, key: key, value: exists); /// Matches values that don't exist. - factory Filter.notExists(String key) => - Filter._(operator: FilterOperator.exists, key: key, value: false); + factory Filter.notExists(String key) => Filter.exists(key, exists: false); /// Matches any list that contains the specified values factory Filter.contains(String key, Object value) => From 4592491b153ff5d8ea6c8a63bf9a6ddfc52676d9 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Tue, 28 Sep 2021 14:09:47 +0530 Subject: [PATCH 4/8] Update packages/stream_chat/CHANGELOG.md Co-authored-by: Salvatore Giordano --- packages/stream_chat/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index c12377b1..cd732218 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -2,7 +2,7 @@ ✅ Added -- `Filter.notExists` now replaces `Filter.exists(key, exists: false)`. +- Added `Filter.notExists`. ## 3.0.0 From 8fd25028d3811e7be1aad5a3f18f2e15695be458 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Tue, 28 Sep 2021 14:10:14 +0530 Subject: [PATCH 5/8] Update packages/stream_chat/lib/src/core/models/filter.dart Co-authored-by: Salvatore Giordano --- packages/stream_chat/lib/src/core/models/filter.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stream_chat/lib/src/core/models/filter.dart b/packages/stream_chat/lib/src/core/models/filter.dart index fb4cfb42..cd53c9e8 100644 --- a/packages/stream_chat/lib/src/core/models/filter.dart +++ b/packages/stream_chat/lib/src/core/models/filter.dart @@ -166,7 +166,7 @@ class Filter extends Equatable { factory Filter.autoComplete(String key, String text) => Filter._(operator: FilterOperator.autoComplete, key: key, value: text); - /// Matches values that exist. + /// Matches values that exist/don't exist based on the specified boolean value. factory Filter.exists(String key, {bool exists = true}) => Filter._(operator: FilterOperator.exists, key: key, value: exists); From 0f9a6c21ac16f88d4e0314974e6436932db986c2 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Tue, 28 Sep 2021 14:10:34 +0530 Subject: [PATCH 6/8] Update packages/stream_chat/lib/src/core/models/filter.dart Co-authored-by: Salvatore Giordano --- packages/stream_chat/lib/src/core/models/filter.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stream_chat/lib/src/core/models/filter.dart b/packages/stream_chat/lib/src/core/models/filter.dart index cd53c9e8..e668c417 100644 --- a/packages/stream_chat/lib/src/core/models/filter.dart +++ b/packages/stream_chat/lib/src/core/models/filter.dart @@ -40,7 +40,7 @@ enum FilterOperator { /// Matches values with the specified prefix. autoComplete, - /// Matches values that exist. + /// Matches values that exist/don't exist based on the specified boolean value. exists, /// Matches values that don't exist. From 517c2cf00b0957409eee160e6d9e3efeaa3ea35e Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Tue, 28 Sep 2021 17:21:52 +0530 Subject: [PATCH 7/8] added docs for Filter.notExists --- .../docs/Flutter/guides/understanding_filters.mdx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docusaurus/docs/Flutter/guides/understanding_filters.mdx b/docusaurus/docs/Flutter/guides/understanding_filters.mdx index e9d72ecf..292afd07 100644 --- a/docusaurus/docs/Flutter/guides/understanding_filters.mdx +++ b/docusaurus/docs/Flutter/guides/understanding_filters.mdx @@ -104,7 +104,16 @@ Filter.autoComplete('name', 'demo') The 'exists' filter matches values that exist, or don't exist, based on the specified boolean value. ```dart -Filter.exists('name', true) +Filter.exists('name') +``` + +#### Filter.notExists + +The 'notExists' filter checks if the specified key doesn't exist. This is a simplified call to `Filter.exists` +with the value set to false. + +```dart +Filter.notExists('name') ``` #### Filter.contains From 4199bc7b6db9345e2512b6689ac150414add1752 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Thu, 30 Sep 2021 16:38:56 +0530 Subject: [PATCH 8/8] removed filteroperator --- packages/stream_chat/lib/src/core/models/filter.dart | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/stream_chat/lib/src/core/models/filter.dart b/packages/stream_chat/lib/src/core/models/filter.dart index e668c417..108efcb2 100644 --- a/packages/stream_chat/lib/src/core/models/filter.dart +++ b/packages/stream_chat/lib/src/core/models/filter.dart @@ -43,9 +43,6 @@ enum FilterOperator { /// Matches values that exist/don't exist based on the specified boolean value. exists, - /// Matches values that don't exist. - notExists, - /// Matches all the values specified in an array. and,