Skip to content

Commit 67c8c13

Browse files
committed
msglist: Display realmEmptyTopicDisplayName where empty topic appears
Signed-off-by: Zixuan James Li <[email protected]>
1 parent d6cf34a commit 67c8c13

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

lib/widgets/message_list.dart

+10-3
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(
@@ -1116,11 +1119,15 @@ class StreamMessageRecipientHeader extends StatelessWidget {
11161119
child: Row(
11171120
children: [
11181121
Flexible(
1119-
child: Text(topic.displayName,
1122+
// ignore: dead_null_aware_expression // null topic names soon to be enabled
1123+
child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName,
11201124
// TODO: Give a way to see the whole topic (maybe a
11211125
// long-press interaction?)
11221126
overflow: TextOverflow.ellipsis,
1123-
style: recipientHeaderTextStyle(context))),
1127+
style: recipientHeaderTextStyle(context).copyWith(
1128+
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
1129+
fontStyle: topic.displayName == null ? FontStyle.italic : null,
1130+
))),
11241131
const SizedBox(width: 4),
11251132
// TODO(design) copies the recipient header in web; is there a better color?
11261133
Icon(size: 14, color: designVariables.colorMessageHeaderIconInteractive,

test/widgets/message_list_test.dart

+20
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,26 @@ void main() {
808808
check(findInMessageList('topic name')).length.equals(1);
809809
});
810810

811+
final messageEmptyTopic = eg.streamMessage(stream: stream, topic: '');
812+
813+
testWidgets('show general chat for empty topics with channel name', (tester) async {
814+
await setupMessageListPage(tester,
815+
narrow: const CombinedFeedNarrow(),
816+
messages: [messageEmptyTopic], subscriptions: [eg.subscription(stream)]);
817+
await tester.pump();
818+
check(findInMessageList('stream name')).single;
819+
check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).single;
820+
}, skip: true); // null topic names soon to be enabled
821+
822+
testWidgets('show general chat for empty topics without channel name', (tester) async {
823+
await setupMessageListPage(tester,
824+
narrow: TopicNarrow.ofMessage(messageEmptyTopic),
825+
messages: [messageEmptyTopic]);
826+
await tester.pump();
827+
check(findInMessageList('stream name')).isEmpty();
828+
check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).single;
829+
}, skip: true); // null topic names soon to be enabled
830+
811831
testWidgets('show topic visibility icon when followed', (tester) async {
812832
await setupMessageListPage(tester,
813833
narrow: const CombinedFeedNarrow(),

0 commit comments

Comments
 (0)