diff --git a/lib/widgets/message_list.dart b/lib/widgets/message_list.dart index 127bd65c61..ad52deec5d 100644 --- a/lib/widgets/message_list.dart +++ b/lib/widgets/message_list.dart @@ -366,8 +366,11 @@ class MessageListAppBarTitle extends StatelessWidget { return Row( mainAxisSize: MainAxisSize.min, children: [ - Flexible(child: Text(topic.displayName, style: const TextStyle( + // ignore: dead_null_aware_expression // null topic names soon to be enabled + Flexible(child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName, style: TextStyle( fontSize: 13, + // ignore: unnecessary_null_comparison // null topic names soon to be enabled + fontStyle: topic.displayName == null ? FontStyle.italic : null, ).merge(weightVariableTextStyle(context)))), if (icon != null) Padding( @@ -1120,11 +1123,15 @@ class StreamMessageRecipientHeader extends StatelessWidget { child: Row( children: [ Flexible( - child: Text(topic.displayName, + // ignore: dead_null_aware_expression // null topic names soon to be enabled + child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName, // TODO: Give a way to see the whole topic (maybe a // long-press interaction?) overflow: TextOverflow.ellipsis, - style: recipientHeaderTextStyle(context))), + style: recipientHeaderTextStyle(context).copyWith( + // ignore: unnecessary_null_comparison // null topic names soon to be enabled + fontStyle: topic.displayName == null ? FontStyle.italic : null, + ))), const SizedBox(width: 4), // TODO(design) copies the recipient header in web; is there a better color? Icon(size: 14, color: designVariables.colorMessageHeaderIconInteractive, diff --git a/test/widgets/message_list_test.dart b/test/widgets/message_list_test.dart index b7384824fd..67d582df11 100644 --- a/test/widgets/message_list_test.dart +++ b/test/widgets/message_list_test.dart @@ -934,6 +934,26 @@ void main() { check(findInMessageList('topic name')).length.equals(1); }); + final messageEmptyTopic = eg.streamMessage(stream: stream, topic: ''); + + testWidgets('show general chat for empty topics with channel name', (tester) async { + await setupMessageListPage(tester, + narrow: const CombinedFeedNarrow(), + messages: [messageEmptyTopic], subscriptions: [eg.subscription(stream)]); + await tester.pump(); + check(findInMessageList('stream name')).single; + check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).single; + }, skip: true); // null topic names soon to be enabled + + testWidgets('show general chat for empty topics without channel name', (tester) async { + await setupMessageListPage(tester, + narrow: TopicNarrow.ofMessage(messageEmptyTopic), + messages: [messageEmptyTopic]); + await tester.pump(); + check(findInMessageList('stream name')).isEmpty(); + check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).single; + }, skip: true); // null topic names soon to be enabled + testWidgets('show topic visibility icon when followed', (tester) async { await setupMessageListPage(tester, narrow: const CombinedFeedNarrow(),