From 29ff91a7909472ad4879a5633232c41db70405b5 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Mon, 24 Aug 2026 21:50:57 -0500 Subject: [PATCH] fix(chat): open the conversation with the other participant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /chat/start/:id starts a chat between the caller and :id, so it takes the counterpart — the web already passes the client when a professional opens it. Mobile always sent the professional, so a professional opening the chat started a conversation with themselves. Co-Authored-By: Claude Opus 5 --- lib/screens/chat/chat_screen.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/screens/chat/chat_screen.dart b/lib/screens/chat/chat_screen.dart index 3f35608..53749cf 100644 --- a/lib/screens/chat/chat_screen.dart +++ b/lib/screens/chat/chat_screen.dart @@ -45,10 +45,18 @@ class _ChatScreenState extends State { } void _loadChat() { + // /chat/start/:id opens the conversation between the caller and :id, so it + // takes the *other* participant. Always sending the professional meant a + // professional opening the chat started a conversation with themselves. + final me = ApiUserRepository.currentUserId ?? ''; + final counterpartId = me == widget.service.professionalId + ? widget.service.userId + : widget.service.professionalId; + chatBloc.add(LoadChatEvent( serviceId: widget.service.id ?? '', userId: widget.service.userId, - professionalId: widget.service.professionalId, + professionalId: counterpartId, )); }