mirror of
https://github.com/Iconica-Development/flutter_chat.git
synced 2025-05-19 10:53:51 +02:00
feat: userFilter
This commit is contained in:
parent
bae97e917e
commit
bd40856e1a
6 changed files with 49 additions and 24 deletions
|
@ -28,7 +28,7 @@ packages:
|
|||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.9.0"
|
||||
version: "2.10.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -179,7 +179,7 @@ packages:
|
|||
description:
|
||||
path: "packages/flutter_community_chat_interface"
|
||||
ref: HEAD
|
||||
resolved-ref: "01ab5599d44c2708b5a0f15959f6f59781ff8eb0"
|
||||
resolved-ref: adc7d063039e44e5a76275bed48d336b18271f3d
|
||||
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
|
@ -188,7 +188,7 @@ packages:
|
|||
description:
|
||||
path: "packages/flutter_community_chat_view"
|
||||
ref: HEAD
|
||||
resolved-ref: "01ab5599d44c2708b5a0f15959f6f59781ff8eb0"
|
||||
resolved-ref: adc7d063039e44e5a76275bed48d336b18271f3d
|
||||
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
|
@ -249,7 +249,7 @@ packages:
|
|||
name: http_parser
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.0.1"
|
||||
version: "4.0.2"
|
||||
image_picker:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -506,7 +506,7 @@ packages:
|
|||
name: string_scanner
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
version: "1.2.0"
|
||||
synchronized:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -7,9 +7,22 @@ class FirebaseChatOptoons {
|
|||
this.chatsCollectionName = 'chats',
|
||||
this.messagesCollectionName = 'messages',
|
||||
this.usersCollectionName = 'users',
|
||||
this.userFilter,
|
||||
});
|
||||
|
||||
final String chatsCollectionName;
|
||||
final String messagesCollectionName;
|
||||
final String usersCollectionName;
|
||||
|
||||
final FirebaseUserFilter? userFilter;
|
||||
}
|
||||
|
||||
class FirebaseUserFilter {
|
||||
const FirebaseUserFilter({
|
||||
required this.field,
|
||||
required this.expectedValue,
|
||||
});
|
||||
|
||||
final String field;
|
||||
final Object expectedValue;
|
||||
}
|
||||
|
|
|
@ -61,9 +61,21 @@ class FirebaseUserService {
|
|||
Future<List<ChatUserModel>> getAllUsers() async {
|
||||
var currentUser = await getCurrentUser();
|
||||
|
||||
var data = await _userCollection.get();
|
||||
var query = _userCollection.where(
|
||||
FieldPath.documentId,
|
||||
isNotEqualTo: currentUser?.id,
|
||||
);
|
||||
|
||||
return data.docs.where((user) => user.id != currentUser?.id).map((user) {
|
||||
if (options.userFilter != null) {
|
||||
query = query.where(
|
||||
options.userFilter!.field,
|
||||
isEqualTo: options.userFilter!.expectedValue,
|
||||
);
|
||||
}
|
||||
|
||||
var data = await query.get();
|
||||
|
||||
return data.docs.map((user) {
|
||||
var userData = user.data();
|
||||
return ChatUserModel(
|
||||
id: user.id,
|
||||
|
|
|
@ -228,7 +228,7 @@ packages:
|
|||
description:
|
||||
path: "packages/flutter_community_chat_interface"
|
||||
ref: HEAD
|
||||
resolved-ref: "01ab5599d44c2708b5a0f15959f6f59781ff8eb0"
|
||||
resolved-ref: adc7d063039e44e5a76275bed48d336b18271f3d
|
||||
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
|
|
|
@ -7,14 +7,14 @@ packages:
|
|||
name: _fe_analyzer_shared
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "49.0.0"
|
||||
version: "50.0.0"
|
||||
analyzer:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: analyzer
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "5.1.0"
|
||||
version: "5.2.0"
|
||||
args:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -56,7 +56,7 @@ packages:
|
|||
name: built_value
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "8.4.1"
|
||||
version: "8.4.2"
|
||||
cached_network_image:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -186,7 +186,7 @@ packages:
|
|||
description:
|
||||
path: "packages/flutter_community_chat_interface"
|
||||
ref: HEAD
|
||||
resolved-ref: "01ab5599d44c2708b5a0f15959f6f59781ff8eb0"
|
||||
resolved-ref: adc7d063039e44e5a76275bed48d336b18271f3d
|
||||
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
|
@ -202,7 +202,7 @@ packages:
|
|||
description:
|
||||
path: "."
|
||||
ref: master
|
||||
resolved-ref: e348c921d5e621975e4f06d3eeff8e8a89dda109
|
||||
resolved-ref: "500ed1d08095b33387ae3aa4ed1a2ad4d2fb2ac3"
|
||||
url: "https://github.com/Iconica-Development/flutter_data_interface.git"
|
||||
source: git
|
||||
version: "1.0.0"
|
||||
|
@ -392,7 +392,7 @@ packages:
|
|||
name: pub_semver
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
version: "2.1.2"
|
||||
rxdart:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -502,14 +502,14 @@ packages:
|
|||
name: watcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
version: "1.0.2"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.1.0"
|
||||
version: "3.1.1"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -7,14 +7,14 @@ packages:
|
|||
name: _fe_analyzer_shared
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "49.0.0"
|
||||
version: "50.0.0"
|
||||
analyzer:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: analyzer
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "5.1.0"
|
||||
version: "5.2.0"
|
||||
args:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -56,7 +56,7 @@ packages:
|
|||
name: built_value
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "8.4.1"
|
||||
version: "8.4.2"
|
||||
cached_network_image:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -179,7 +179,7 @@ packages:
|
|||
description:
|
||||
path: "packages/flutter_community_chat_interface"
|
||||
ref: HEAD
|
||||
resolved-ref: "01ab5599d44c2708b5a0f15959f6f59781ff8eb0"
|
||||
resolved-ref: adc7d063039e44e5a76275bed48d336b18271f3d
|
||||
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
|
@ -188,7 +188,7 @@ packages:
|
|||
description:
|
||||
path: "."
|
||||
ref: master
|
||||
resolved-ref: e348c921d5e621975e4f06d3eeff8e8a89dda109
|
||||
resolved-ref: "500ed1d08095b33387ae3aa4ed1a2ad4d2fb2ac3"
|
||||
url: "https://github.com/Iconica-Development/flutter_data_interface.git"
|
||||
source: git
|
||||
version: "1.0.0"
|
||||
|
@ -378,7 +378,7 @@ packages:
|
|||
name: pub_semver
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
version: "2.1.2"
|
||||
rxdart:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -488,14 +488,14 @@ packages:
|
|||
name: watcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
version: "1.0.2"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.1.0"
|
||||
version: "3.1.1"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
Loading…
Reference in a new issue