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 Freek van de Ven
parent acbb809a57
commit d298fbe15b
2 changed files with 8 additions and 2 deletions

View file

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

View file

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