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
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.9.0"
|
version: "2.10.0"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -179,7 +179,7 @@ packages:
|
||||||
description:
|
description:
|
||||||
path: "packages/flutter_community_chat_interface"
|
path: "packages/flutter_community_chat_interface"
|
||||||
ref: HEAD
|
ref: HEAD
|
||||||
resolved-ref: "01ab5599d44c2708b5a0f15959f6f59781ff8eb0"
|
resolved-ref: adc7d063039e44e5a76275bed48d336b18271f3d
|
||||||
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
|
@ -188,7 +188,7 @@ packages:
|
||||||
description:
|
description:
|
||||||
path: "packages/flutter_community_chat_view"
|
path: "packages/flutter_community_chat_view"
|
||||||
ref: HEAD
|
ref: HEAD
|
||||||
resolved-ref: "01ab5599d44c2708b5a0f15959f6f59781ff8eb0"
|
resolved-ref: adc7d063039e44e5a76275bed48d336b18271f3d
|
||||||
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
|
@ -249,7 +249,7 @@ packages:
|
||||||
name: http_parser
|
name: http_parser
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.1"
|
version: "4.0.2"
|
||||||
image_picker:
|
image_picker:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -506,7 +506,7 @@ packages:
|
||||||
name: string_scanner
|
name: string_scanner
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.1"
|
version: "1.2.0"
|
||||||
synchronized:
|
synchronized:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -7,9 +7,22 @@ class FirebaseChatOptoons {
|
||||||
this.chatsCollectionName = 'chats',
|
this.chatsCollectionName = 'chats',
|
||||||
this.messagesCollectionName = 'messages',
|
this.messagesCollectionName = 'messages',
|
||||||
this.usersCollectionName = 'users',
|
this.usersCollectionName = 'users',
|
||||||
|
this.userFilter,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String chatsCollectionName;
|
final String chatsCollectionName;
|
||||||
final String messagesCollectionName;
|
final String messagesCollectionName;
|
||||||
final String usersCollectionName;
|
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 {
|
Future<List<ChatUserModel>> getAllUsers() async {
|
||||||
var currentUser = await getCurrentUser();
|
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();
|
var userData = user.data();
|
||||||
return ChatUserModel(
|
return ChatUserModel(
|
||||||
id: user.id,
|
id: user.id,
|
||||||
|
|
|
@ -228,7 +228,7 @@ packages:
|
||||||
description:
|
description:
|
||||||
path: "packages/flutter_community_chat_interface"
|
path: "packages/flutter_community_chat_interface"
|
||||||
ref: HEAD
|
ref: HEAD
|
||||||
resolved-ref: "01ab5599d44c2708b5a0f15959f6f59781ff8eb0"
|
resolved-ref: adc7d063039e44e5a76275bed48d336b18271f3d
|
||||||
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
|
|
|
@ -7,14 +7,14 @@ packages:
|
||||||
name: _fe_analyzer_shared
|
name: _fe_analyzer_shared
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "49.0.0"
|
version: "50.0.0"
|
||||||
analyzer:
|
analyzer:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: analyzer
|
name: analyzer
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.1.0"
|
version: "5.2.0"
|
||||||
args:
|
args:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -56,7 +56,7 @@ packages:
|
||||||
name: built_value
|
name: built_value
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "8.4.1"
|
version: "8.4.2"
|
||||||
cached_network_image:
|
cached_network_image:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -186,7 +186,7 @@ packages:
|
||||||
description:
|
description:
|
||||||
path: "packages/flutter_community_chat_interface"
|
path: "packages/flutter_community_chat_interface"
|
||||||
ref: HEAD
|
ref: HEAD
|
||||||
resolved-ref: "01ab5599d44c2708b5a0f15959f6f59781ff8eb0"
|
resolved-ref: adc7d063039e44e5a76275bed48d336b18271f3d
|
||||||
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
|
@ -202,7 +202,7 @@ packages:
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: master
|
ref: master
|
||||||
resolved-ref: e348c921d5e621975e4f06d3eeff8e8a89dda109
|
resolved-ref: "500ed1d08095b33387ae3aa4ed1a2ad4d2fb2ac3"
|
||||||
url: "https://github.com/Iconica-Development/flutter_data_interface.git"
|
url: "https://github.com/Iconica-Development/flutter_data_interface.git"
|
||||||
source: git
|
source: git
|
||||||
version: "1.0.0"
|
version: "1.0.0"
|
||||||
|
@ -392,7 +392,7 @@ packages:
|
||||||
name: pub_semver
|
name: pub_semver
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "2.1.2"
|
||||||
rxdart:
|
rxdart:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -502,14 +502,14 @@ packages:
|
||||||
name: watcher
|
name: watcher
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.1"
|
version: "1.0.2"
|
||||||
win32:
|
win32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: win32
|
name: win32
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.0"
|
version: "3.1.1"
|
||||||
xdg_directories:
|
xdg_directories:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -7,14 +7,14 @@ packages:
|
||||||
name: _fe_analyzer_shared
|
name: _fe_analyzer_shared
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "49.0.0"
|
version: "50.0.0"
|
||||||
analyzer:
|
analyzer:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: analyzer
|
name: analyzer
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.1.0"
|
version: "5.2.0"
|
||||||
args:
|
args:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -56,7 +56,7 @@ packages:
|
||||||
name: built_value
|
name: built_value
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "8.4.1"
|
version: "8.4.2"
|
||||||
cached_network_image:
|
cached_network_image:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -179,7 +179,7 @@ packages:
|
||||||
description:
|
description:
|
||||||
path: "packages/flutter_community_chat_interface"
|
path: "packages/flutter_community_chat_interface"
|
||||||
ref: HEAD
|
ref: HEAD
|
||||||
resolved-ref: "01ab5599d44c2708b5a0f15959f6f59781ff8eb0"
|
resolved-ref: adc7d063039e44e5a76275bed48d336b18271f3d
|
||||||
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
|
@ -188,7 +188,7 @@ packages:
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: master
|
ref: master
|
||||||
resolved-ref: e348c921d5e621975e4f06d3eeff8e8a89dda109
|
resolved-ref: "500ed1d08095b33387ae3aa4ed1a2ad4d2fb2ac3"
|
||||||
url: "https://github.com/Iconica-Development/flutter_data_interface.git"
|
url: "https://github.com/Iconica-Development/flutter_data_interface.git"
|
||||||
source: git
|
source: git
|
||||||
version: "1.0.0"
|
version: "1.0.0"
|
||||||
|
@ -378,7 +378,7 @@ packages:
|
||||||
name: pub_semver
|
name: pub_semver
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "2.1.2"
|
||||||
rxdart:
|
rxdart:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -488,14 +488,14 @@ packages:
|
||||||
name: watcher
|
name: watcher
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.1"
|
version: "1.0.2"
|
||||||
win32:
|
win32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: win32
|
name: win32
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.0"
|
version: "3.1.1"
|
||||||
xdg_directories:
|
xdg_directories:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
Loading…
Reference in a new issue