Skip to content

Commit

Permalink
fix: dont show avatars for not bad encrypted messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier committed Jan 10, 2025
1 parent 4220965 commit f492929
Showing 1 changed file with 33 additions and 22 deletions.
55 changes: 33 additions & 22 deletions lib/chat/view/events/chat_message_bubble.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,27 +136,6 @@ class _ChatMessageBubbleContent extends StatelessWidget {
final messageStyle = textTheme.bodyMedium;
final displayEvent = event.getDisplayEvent(timeline);

final hide = hideAvatar && event.messageType == MessageTypes.Text;

final Widget chatBubbleAvatar;
if (hide) {
chatBubbleAvatar = const SizedBox.shrink();
} else {
chatBubbleAvatar = event.messageType == MessageTypes.Text
? ChatAvatar(
avatarUri: event.senderFromMemoryOrFallback.avatarUrl,
onTap: () => showDialog(
context: context,
builder: (context) => ChatProfileDialog(userId: event.senderId),
),
fallBackColor: getMonochromeBg(
theme: context.theme,
factor: 10,
darkFactor: yaru ? 1 : null,
),
)
: ChatMessageMediaAvatar(event: event);
}
return Material(
color: Colors.transparent,
child: Row(
Expand All @@ -166,7 +145,11 @@ class _ChatMessageBubbleContent extends StatelessWidget {
children: [
Padding(
padding: const EdgeInsets.all(kSmallPadding),
child: chatBubbleAvatar,
child: hideAvatar && event.messageType == MessageTypes.Text
? const SizedBox.shrink()
: ChatMessageBubbleLeading(
event: event,
),
),
Flexible(
child: Column(
Expand Down Expand Up @@ -232,3 +215,31 @@ class _ChatMessageBubbleContent extends StatelessWidget {
);
}
}

class ChatMessageBubbleLeading extends StatelessWidget {
const ChatMessageBubbleLeading({super.key, required this.event});

final Event event;

@override
Widget build(BuildContext context) {
if (event.messageType == MessageTypes.BadEncrypted) {
return const SizedBox.shrink();
} else if (event.messageType != MessageTypes.Text) {
return ChatMessageMediaAvatar(event: event);
}

return ChatAvatar(
avatarUri: event.senderFromMemoryOrFallback.avatarUrl,
onTap: () => showDialog(
context: context,
builder: (context) => ChatProfileDialog(userId: event.senderId),
),
fallBackColor: getMonochromeBg(
theme: context.theme,
factor: 10,
darkFactor: yaru ? 1 : null,
),
);
}
}

0 comments on commit f492929

Please sign in to comment.