fix: prevent duplicate messages and update support chat UI styling
This commit is contained in:
@@ -55,9 +55,14 @@ class _SupportChatScreenState extends ConsumerState<SupportChatScreen> {
|
||||
socket.emitRaw('support_join', {'chatId': chatId});
|
||||
}
|
||||
|
||||
// Listen for new support messages
|
||||
// Listen for new support messages — skip own (added via REST)
|
||||
_messageSub?.cancel();
|
||||
_messageSub = socket.onSupportMessage.listen((message) {
|
||||
// Get fresh userId — currentUserId from build() may have been empty at capture time
|
||||
final myId = currentUserId.isNotEmpty
|
||||
? currentUserId
|
||||
: ref.read(authProvider).user?.id ?? '';
|
||||
if (message.senderId == myId) return;
|
||||
ref.read(supportChatProvider.notifier).addIncomingMessage(message);
|
||||
_scrollToBottom();
|
||||
});
|
||||
@@ -199,9 +204,7 @@ class _SupportChatScreenState extends ConsumerState<SupportChatScreen> {
|
||||
}
|
||||
});
|
||||
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
return Column(
|
||||
children: [
|
||||
// Chat header
|
||||
_buildHeader(context, state.chat),
|
||||
@@ -223,8 +226,6 @@ class _SupportChatScreenState extends ConsumerState<SupportChatScreen> {
|
||||
if (!state.isLoading && state.error == null)
|
||||
_buildInputArea(state),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -232,8 +233,7 @@ class _SupportChatScreenState extends ConsumerState<SupportChatScreen> {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
decoration: const BoxDecoration(
|
||||
color: AppColors.primaryDark,
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(0)),
|
||||
color: Color(0xFF648188),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
@@ -457,7 +457,7 @@ class _SupportChatScreenState extends ConsumerState<SupportChatScreen> {
|
||||
maxWidth: MediaQuery.of(context).size.width * 0.75,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: isOwn ? AppColors.primaryDark : Colors.white,
|
||||
color: isOwn ? const Color(0xFF648188) : Colors.white,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: const Radius.circular(15),
|
||||
topRight: const Radius.circular(15),
|
||||
|
||||
Reference in New Issue
Block a user