mirror of
https://github.com/Iconica-Development/flutter_chat.git
synced 2025-05-19 10:53:51 +02:00
fix: use ChatService instead of UserRepository directly for getAllUsersForChat
This commit is contained in:
parent
acbb809a57
commit
d298fbe15b
2 changed files with 8 additions and 2 deletions
|
@ -224,4 +224,9 @@ class ChatService {
|
||||||
|
|
||||||
await chatRepository.updateChat(chat: newChat);
|
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) {
|
Widget build(BuildContext context) {
|
||||||
var chatScope = ChatScope.of(context);
|
var chatScope = ChatScope.of(context);
|
||||||
var options = chatScope.options;
|
var options = chatScope.options;
|
||||||
|
var service = chatScope.service;
|
||||||
|
|
||||||
var chatTitle = useState<String?>(null);
|
var chatTitle = useState<String?>(null);
|
||||||
|
|
||||||
var chatStream = useMemoized(
|
var chatStream = useMemoized(
|
||||||
() => chatScope.service.getChat(chatId: chatId),
|
() => service.getChat(chatId: chatId),
|
||||||
[chatId],
|
[chatId],
|
||||||
);
|
);
|
||||||
var chatSnapshot = useStream(chatStream);
|
var chatSnapshot = useStream(chatStream);
|
||||||
var chat = chatSnapshot.data;
|
var chat = chatSnapshot.data;
|
||||||
|
|
||||||
var allUsersStream = useMemoized(
|
var allUsersStream = useMemoized(
|
||||||
() => options.userRepository.getAllUsersForChat(chatId: chatId),
|
() => service.getAllUsersForChat(chatId: chatId),
|
||||||
[chatId],
|
[chatId],
|
||||||
);
|
);
|
||||||
var usersSnapshot = useStream(allUsersStream);
|
var usersSnapshot = useStream(allUsersStream);
|
||||||
|
|
Loading…
Reference in a new issue