Skip to content

Commit 80eee16

Browse files
committed
msglist [nfc]: Display realmEmptyTopicDisplayName where empty topic appears
Signed-off-by: Zixuan James Li <[email protected]>
1 parent e8e2f33 commit 80eee16

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

lib/widgets/message_list.dart

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,11 @@ class MessageListAppBarTitle extends StatelessWidget {
366366
return Row(
367367
mainAxisSize: MainAxisSize.min,
368368
children: [
369-
Flexible(child: Text(topic.displayName, style: const TextStyle(
369+
// ignore: dead_null_aware_expression // null topic names soon to be enabled
370+
Flexible(child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName, style: TextStyle(
370371
fontSize: 13,
372+
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
373+
fontStyle: topic.displayName == null ? FontStyle.italic : null,
371374
).merge(weightVariableTextStyle(context)))),
372375
if (icon != null)
373376
Padding(
@@ -1119,11 +1122,15 @@ class StreamMessageRecipientHeader extends StatelessWidget {
11191122
child: Row(
11201123
children: [
11211124
Flexible(
1122-
child: Text(topic.displayName,
1125+
// ignore: dead_null_aware_expression // null topic names soon to be enabled
1126+
child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName,
11231127
// TODO: Give a way to see the whole topic (maybe a
11241128
// long-press interaction?)
11251129
overflow: TextOverflow.ellipsis,
1126-
style: recipientHeaderTextStyle(context))),
1130+
style: recipientHeaderTextStyle(context).copyWith(
1131+
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
1132+
fontStyle: topic.displayName == null ? FontStyle.italic : null,
1133+
))),
11271134
const SizedBox(width: 4),
11281135
// TODO(design) copies the recipient header in web; is there a better color?
11291136
Icon(size: 14, color: designVariables.colorMessageHeaderIconInteractive,

test/widgets/message_list_test.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,26 @@ void main() {
934934
check(findInMessageList('topic name')).length.equals(1);
935935
});
936936

937+
final messageEmptyTopic = eg.streamMessage(stream: stream, topic: '');
938+
939+
testWidgets('show general chat for empty topics with channel name', (tester) async {
940+
await setupMessageListPage(tester,
941+
narrow: const CombinedFeedNarrow(),
942+
messages: [messageEmptyTopic], subscriptions: [eg.subscription(stream)]);
943+
await tester.pump();
944+
check(findInMessageList('stream name')).single;
945+
check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).single;
946+
}, skip: true); // null topic names soon to be enabled
947+
948+
testWidgets('show general chat for empty topics without channel name', (tester) async {
949+
await setupMessageListPage(tester,
950+
narrow: TopicNarrow.ofMessage(messageEmptyTopic),
951+
messages: [messageEmptyTopic]);
952+
await tester.pump();
953+
check(findInMessageList('stream name')).isEmpty();
954+
check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).single;
955+
}, skip: true); // null topic names soon to be enabled
956+
937957
testWidgets('show topic visibility icon when followed', (tester) async {
938958
await setupMessageListPage(tester,
939959
narrow: const CombinedFeedNarrow(),

0 commit comments

Comments
 (0)