Skip to content

Commit 7bdef99

Browse files
committed
msglist: Display realmEmptyTopicDisplayName on empty topic
Signed-off-by: Zixuan James Li <[email protected]>
1 parent d9537d0 commit 7bdef99

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) ? FontStyle.italic : null,
367370
).merge(weightVariableTextStyle(context)))),
368371
if (icon != null)
369372
Padding(
@@ -1094,11 +1097,15 @@ class StreamMessageRecipientHeader extends StatelessWidget {
10941097
child: Row(
10951098
children: [
10961099
Flexible(
1097-
child: Text(topic.displayName,
1100+
// ignore: dead_null_aware_expression // null topic names soon to be enabled
1101+
child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName,
10981102
// TODO: Give a way to see the whole topic (maybe a
10991103
// long-press interaction?)
11001104
overflow: TextOverflow.ellipsis,
1101-
style: recipientHeaderTextStyle(context))),
1105+
style: recipientHeaderTextStyle(context).copyWith(
1106+
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
1107+
fontStyle: (topic.displayName == null) ? FontStyle.italic : null,
1108+
))),
11021109
const SizedBox(width: 4),
11031110
// TODO(design) copies the recipient header in web; is there a better color?
11041111
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
@@ -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')).length.equals(1);
819+
check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).length.equals(1);
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')).length.equals(0);
828+
check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).length.equals(1);
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)