mirror of
https://github.com/Iconica-Development/flutter_chat.git
synced 2025-05-18 18:33:49 +02:00
fix: use ChatService instead of UserRepository directly for getAllUsersForChat
This commit is contained in:
parent
d475cf7298
commit
5d29e733aa
2 changed files with 8 additions and 2 deletions
|
@ -224,4 +224,9 @@ class ChatService {
|
|||
|
||||
await chatRepository.updateChat(chat: newChat);
|
||||
}
|
||||
|
||||
/// Get all the users for the given [chatId].
|
||||
/// Returns a list of [UserModel] stream.
|
||||
Stream<List<UserModel>> getAllUsersForChat({required String chatId}) =>
|
||||
userRepository.getAllUsersForChat(chatId: chatId);
|
||||
}
|
||||
|
|
|
@ -50,18 +50,19 @@ class ChatDetailScreen extends HookWidget {
|
|||
Widget build(BuildContext context) {
|
||||
var chatScope = ChatScope.of(context);
|
||||
var options = chatScope.options;
|
||||
var service = chatScope.service;
|
||||
|
||||
var chatTitle = useState<String?>(null);
|
||||
|
||||
var chatStream = useMemoized(
|
||||
() => chatScope.service.getChat(chatId: chatId),
|
||||
() => service.getChat(chatId: chatId),
|
||||
[chatId],
|
||||
);
|
||||
var chatSnapshot = useStream(chatStream);
|
||||
var chat = chatSnapshot.data;
|
||||
|
||||
var allUsersStream = useMemoized(
|
||||
() => options.userRepository.getAllUsersForChat(chatId: chatId),
|
||||
() => service.getAllUsersForChat(chatId: chatId),
|
||||
[chatId],
|
||||
);
|
||||
var usersSnapshot = useStream(allUsersStream);
|
||||
|
|
Loading…
Reference in a new issue