fix(chat): open the conversation with the other participant
ci-651288 / run (push) Waiting to run
ci-946620 / run (push) Waiting to run

/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 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-08-24 21:50:57 -05:00
co-authored by Claude Opus 5
parent 7930890d09
commit 29ff91a790
+9 -1
View File
@@ -45,10 +45,18 @@ class _ChatScreenState extends State<ChatScreen> {
}
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,
));
}