filtered deleted messages from search and chat view, refactored chat bubble styling for deleted comments, and updated tests

This commit is contained in:
2026-05-09 22:28:26 +02:00
parent 7d02e70459
commit 79a6d9a594
4 changed files with 65 additions and 35 deletions
+5 -1
View File
@@ -178,6 +178,7 @@ class _ChatViewState extends State<ChatView> {
if (element.systemMessage.contains('reaction')) continue; if (element.systemMessage.contains('reaction')) continue;
if (element.systemMessage.contains('poll_voted')) continue; if (element.systemMessage.contains('poll_voted')) continue;
if (element.systemMessage.contains('message_deleted')) continue;
final commonRead = int.parse( final commonRead = int.parse(
response.headers?['x-chat-last-common-read'] ?? '0', response.headers?['x-chat-last-common-read'] ?? '0',
); );
@@ -209,7 +210,10 @@ class _ChatViewState extends State<ChatView> {
context: context, context: context,
isSender: isSender:
element.actorId == widget.selfId && element.actorId == widget.selfId &&
element.messageType == GetRoomResponseObjectMessageType.comment, (element.messageType ==
GetRoomResponseObjectMessageType.comment ||
element.messageType ==
GetRoomResponseObjectMessageType.deletedComment),
bubbleData: element, bubbleData: element,
chatData: widget.room, chatData: widget.room,
refetch: ({bool renew = false}) => _refresh(), refetch: ({bool renew = false}) => _refresh(),
@@ -21,6 +21,7 @@ class ChatSearchController {
for (final element in response.sortByTimestamp()) { for (final element in response.sortByTimestamp()) {
if (element.systemMessage.contains('reaction')) continue; if (element.systemMessage.contains('reaction')) continue;
if (element.systemMessage.contains('poll_voted')) continue; if (element.systemMessage.contains('poll_voted')) continue;
if (element.systemMessage.contains('message_deleted')) continue;
final haystackText = RichObjectStringProcessor.parseToString( final haystackText = RichObjectStringProcessor.parseToString(
element.message, element.message,
+27 -12
View File
@@ -148,11 +148,33 @@ class _ChatBubbleState extends State<ChatBubble>
).asDialog(context); ).asDialog(context);
} }
bool get _rendersAsCommentBubble =>
widget.bubbleData.messageType ==
GetRoomResponseObjectMessageType.comment ||
widget.bubbleData.messageType ==
GetRoomResponseObjectMessageType.deletedComment;
TextStyle? _messageTextStyle(BuildContext context) {
final theme = Theme.of(context);
switch (widget.bubbleData.messageType) {
case GetRoomResponseObjectMessageType.system:
return theme.textTheme.bodySmall;
case GetRoomResponseObjectMessageType.deletedComment:
return theme.textTheme.bodyMedium?.copyWith(
color: theme.hintColor,
fontStyle: FontStyle.italic,
);
case GetRoomResponseObjectMessageType.comment:
case GetRoomResponseObjectMessageType.voiceMessage:
case GetRoomResponseObjectMessageType.command:
return null;
}
}
BubbleStyle _getStyle() { BubbleStyle _getStyle() {
final styles = ChatBubbleStyles(context); final styles = ChatBubbleStyles(context);
final BubbleStyle base; final BubbleStyle base;
if (widget.bubbleData.messageType != if (!_rendersAsCommentBubble) {
GetRoomResponseObjectMessageType.comment) {
base = styles.getSystemStyle(); base = styles.getSystemStyle();
} else { } else {
base = widget.isSender base = widget.isSender
@@ -210,14 +232,11 @@ class _ChatBubbleState extends State<ChatBubble>
originalData: widget.bubbleData.messageParameters, originalData: widget.bubbleData.messageParameters,
); );
final showActorDisplayName = final showActorDisplayName =
widget.bubbleData.messageType == _rendersAsCommentBubble &&
GetRoomResponseObjectMessageType.comment &&
widget.chatData.type != GetRoomResponseObjectConversationType.oneToOne; widget.chatData.type != GetRoomResponseObjectConversationType.oneToOne;
final showBubbleTime = final showBubbleTime =
widget.bubbleData.messageType != widget.bubbleData.messageType !=
GetRoomResponseObjectMessageType.system && GetRoomResponseObjectMessageType.system;
widget.bubbleData.messageType !=
GetRoomResponseObjectMessageType.deletedComment;
final parent = widget.bubbleData.parent; final parent = widget.bubbleData.parent;
final actorBaseStyle = TextStyle( final actorBaseStyle = TextStyle(
@@ -294,11 +313,7 @@ class _ChatBubbleState extends State<ChatBubble>
timeText: timeText, timeText: timeText,
messageWidget: message.getWidget( messageWidget: message.getWidget(
highlightQuery: widget.highlightQuery, highlightQuery: widget.highlightQuery,
style: style: _messageTextStyle(context),
widget.bubbleData.messageType ==
GetRoomResponseObjectMessageType.system
? Theme.of(context).textTheme.bodySmall
: null,
), ),
parent: parent, parent: parent,
bubbleData: widget.bubbleData, bubbleData: widget.bubbleData,
+32 -22
View File
@@ -105,28 +105,38 @@ void main() {
); );
}); });
test('reaction and poll_voted system messages are filtered out', () { test(
final response = _response([ 'reaction, poll_voted and message_deleted system messages are filtered out',
_msg( () {
id: 1, final response = _response([
timestamp: 100, _msg(
message: 'Treffer', id: 1,
systemMessage: 'reaction', timestamp: 100,
type: GetRoomResponseObjectMessageType.system, message: 'Treffer',
), systemMessage: 'reaction',
_msg( type: GetRoomResponseObjectMessageType.system,
id: 2, ),
timestamp: 200, _msg(
message: 'Treffer', id: 2,
systemMessage: 'poll_voted', timestamp: 200,
type: GetRoomResponseObjectMessageType.system, message: 'Treffer',
), systemMessage: 'poll_voted',
_msg(id: 3, timestamp: 300, message: 'Treffer'), type: GetRoomResponseObjectMessageType.system,
]); ),
final matches = ChatSearchController.findMatches(response, 'Treffer'); _msg(
expect(matches.length, 1); id: 4,
expect(matches.first.messageId, 3); timestamp: 250,
}); message: 'Treffer',
systemMessage: 'message_deleted',
type: GetRoomResponseObjectMessageType.system,
),
_msg(id: 3, timestamp: 300, message: 'Treffer'),
]);
final matches = ChatSearchController.findMatches(response, 'Treffer');
expect(matches.length, 1);
expect(matches.first.messageId, 3);
},
);
test('rich object parameters are searchable (e.g. file names)', () { test('rich object parameters are searchable (e.g. file names)', () {
final response = _response([ final response = _response([