fix: use ChatService instead of UserRepository directly for getAllUsersForChat

This commit is contained in:
Freek van de Ven 2025-02-14 08:42:52 +01:00 committed by FlutterJoey
parent d475cf7298
commit 5d29e733aa
2 changed files with 8 additions and 2 deletions

View file

@ -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);
}

View file

@ -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);