diff --git a/lib/pages/chat/events/message/message.dart b/lib/pages/chat/events/message/message.dart index fcbf828d6..a7560d4ba 100644 --- a/lib/pages/chat/events/message/message.dart +++ b/lib/pages/chat/events/message/message.dart @@ -311,13 +311,19 @@ class _MessageState extends State { ); } + bool shouldDisplayAvatar(bool sameSender, bool ownMessage) { + return sameSender && + (!ownMessage || !Message.responsiveUtils.isMobile(context)); + } + Widget _placeHolderWidget(bool sameSender, bool ownMessage, Event event) { - if (widget.selectMode || event.room.isDirectChat) { + if (widget.selectMode || + (event.room.isDirectChat && + Message.responsiveUtils.isMobile(context))) { return const SizedBox(); } - if (sameSender && - (!ownMessage || !Message.responsiveUtils.isMobile(context))) { + if (shouldDisplayAvatar(sameSender, ownMessage)) { return Padding( padding: MessageStyle.paddingAvatar, child: FutureBuilder( diff --git a/lib/pages/chat/events/message/message_content_builder.dart b/lib/pages/chat/events/message/message_content_builder.dart index aebab9e54..05d45469b 100644 --- a/lib/pages/chat/events/message/message_content_builder.dart +++ b/lib/pages/chat/events/message/message_content_builder.dart @@ -7,6 +7,7 @@ import 'package:flutter/material.dart'; import 'package:fluffychat/pages/chat/events/message/reply_content_widget.dart'; import 'package:fluffychat/pages/chat/events/message_content.dart'; import 'package:matrix/matrix.dart' hide Visibility; +import 'message.dart'; class MessageContentBuilder extends StatelessWidget with MessageContentBuilderMixin { @@ -46,6 +47,7 @@ class MessageContentBuilder extends StatelessWidget ownMessage: event.isOwnMessage, hideDisplayName: event.hideDisplayName( nextEvent, + Message.responsiveUtils.isMobile(context), ), ); final stepWidth = sizeMessageBubble?.totalMessageWidth; diff --git a/lib/pages/chat/events/message/message_content_with_timestamp_builder.dart b/lib/pages/chat/events/message/message_content_with_timestamp_builder.dart index b5b403f23..5bdf0cf4d 100644 --- a/lib/pages/chat/events/message/message_content_with_timestamp_builder.dart +++ b/lib/pages/chat/events/message/message_content_with_timestamp_builder.dart @@ -138,7 +138,10 @@ class MessageContentWithTimestampBuilder extends StatelessWidget { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - event.hideDisplayName(nextEvent) + event.hideDisplayName( + nextEvent, + responsiveUtils.isMobile(context), + ) ? const SizedBox() : DisplayNameWidget( event: event, diff --git a/lib/utils/matrix_sdk_extensions/event_extension.dart b/lib/utils/matrix_sdk_extensions/event_extension.dart index f0a31a54a..633188f9e 100644 --- a/lib/utils/matrix_sdk_extensions/event_extension.dart +++ b/lib/utils/matrix_sdk_extensions/event_extension.dart @@ -176,7 +176,8 @@ extension LocalizedBody on Event { MessageTypes.File, }.contains(messageType); - bool hideDisplayName(Event? nextEvent) => + bool hideDisplayName(Event? nextEvent, bool isMobile) => + (isMobile && isOwnMessage) || room.isDirectChat || !isSameSenderWith(nextEvent) || type == EventTypes.Encrypted;