feat: Implement socket-first message sending with REST fallback, enhance chat room re-joining on socket reconnect, and update 'Categories' to 'Specialization' in the hero section.

This commit is contained in:
pradeepkumar
2026-03-16 17:49:25 +05:30
parent d86c862ed7
commit 26d9197548
3 changed files with 33 additions and 16 deletions

View File

@@ -291,7 +291,20 @@ class MessagingNotifier extends StateNotifier<MessagingState> {
);
try {
final realMessage = await _repository.sendMessage(
// Send via socket so the backend broadcasts new_message to the other user.
// The REST endpoint does NOT emit socket events, so using REST here
// would prevent real-time delivery to the other participant.
ChatMessage? realMessage;
if (_socket.isConnected) {
realMessage = await _socket.sendMessage(conversationId, {
'content': content,
'messageType': 'TEXT',
});
}
// Fallback to REST if socket send failed or not connected
realMessage ??= await _repository.sendMessage(
conversationId,
content: content,
);
@@ -311,7 +324,7 @@ class MessagingNotifier extends StateNotifier<MessagingState> {
final updatedConversations = state.conversations.map((c) {
if (c.id == conversationId) {
return c.copyWith(
lastMessageText: realMessage.content,
lastMessageText: realMessage!.content,
lastMessageAt: realMessage.createdAt,
);
}