Skip to content

Commit 5e7cc48

Browse files
committed
msglist: Display realmEmptyTopicDisplayName on empty topic
Signed-off-by: Zixuan James Li <[email protected]>
1 parent 746791f commit 5e7cc48

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
@@ -362,8 +362,11 @@ class MessageListAppBarTitle extends StatelessWidget {
362362
return Row(
363363
mainAxisSize: MainAxisSize.min,
364364
children: [
365-
Flexible(child: Text(topic.displayName, style: const TextStyle(
365+
// ignore: dead_null_aware_expression // null topic names soon to be enabled
366+
Flexible(child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName, style: TextStyle(
366367
fontSize: 13,
368+
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
369+
fontStyle: (topic.displayName == null) ? null : FontStyle.italic,
367370
).merge(weightVariableTextStyle(context)))),
368371
if (icon != null)
369372
Padding(
@@ -1095,11 +1098,15 @@ class StreamMessageRecipientHeader extends StatelessWidget {
10951098
child: Row(
10961099
children: [
10971100
Flexible(
1098-
child: Text(topic.displayName,
1101+
// ignore: dead_null_aware_expression // null topic names soon to be enabled
1102+
child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName,
10991103
// TODO: Give a way to see the whole topic (maybe a
11001104
// long-press interaction?)
11011105
overflow: TextOverflow.ellipsis,
1102-
style: recipientHeaderTextStyle(context))),
1106+
style: recipientHeaderTextStyle(context).copyWith(
1107+
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
1108+
fontStyle: (topic.displayName == null) ? null : FontStyle.italic,
1109+
))),
11031110
const SizedBox(width: 4),
11041111
// TODO(design) copies the recipient header in web; is there a better color?
11051112
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
@@ -804,6 +804,26 @@ void main() {
804804
check(findInMessageList('topic name')).length.equals(1);
805805
});
806806

807+
final messageEmptyTopic = eg.streamMessage(stream: stream, topic: '');
808+
809+
testWidgets('show general chat for empty topics with channel name', (tester) async {
810+
await setupMessageListPage(tester,
811+
narrow: const CombinedFeedNarrow(),
812+
messages: [messageEmptyTopic], subscriptions: [eg.subscription(stream)]);
813+
await tester.pump();
814+
check(findInMessageList('stream name')).length.equals(1);
815+
check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).length.equals(1);
816+
}, skip: true); // null topic names soon to be enabled
817+
818+
testWidgets('show general chat for empty topics without channel name', (tester) async {
819+
await setupMessageListPage(tester,
820+
narrow: TopicNarrow.ofMessage(messageEmptyTopic),
821+
messages: [messageEmptyTopic]);
822+
await tester.pump();
823+
check(findInMessageList('stream name')).length.equals(0);
824+
check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).length.equals(1);
825+
}, skip: true); // null topic names soon to be enabled
826+
807827
testWidgets('show topic visibility icon when followed', (tester) async {
808828
await setupMessageListPage(tester,
809829
narrow: const CombinedFeedNarrow(),

0 commit comments

Comments
 (0)