Skip to content

Commit 04a8340

Browse files
committed
msglist: Display realmEmptyTopicDisplayName where empty topic appears
Signed-off-by: Zixuan James Li <[email protected]>
1 parent 45bbeab commit 04a8340

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(
@@ -1117,11 +1120,15 @@ class StreamMessageRecipientHeader extends StatelessWidget {
11171120
child: Row(
11181121
children: [
11191122
Flexible(
1120-
child: Text(topic.displayName,
1123+
// ignore: dead_null_aware_expression // null topic names soon to be enabled
1124+
child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName,
11211125
// TODO: Give a way to see the whole topic (maybe a
11221126
// long-press interaction?)
11231127
overflow: TextOverflow.ellipsis,
1124-
style: recipientHeaderTextStyle(context))),
1128+
style: recipientHeaderTextStyle(context).copyWith(
1129+
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
1130+
fontStyle: topic.displayName == null ? FontStyle.italic : null,
1131+
))),
11251132
const SizedBox(width: 4),
11261133
// TODO(design) copies the recipient header in web; is there a better color?
11271134
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
@@ -853,6 +853,26 @@ void main() {
853853
check(findInMessageList('topic name')).length.equals(1);
854854
});
855855

856+
final messageEmptyTopic = eg.streamMessage(stream: stream, topic: '');
857+
858+
testWidgets('show general chat for empty topics with channel name', (tester) async {
859+
await setupMessageListPage(tester,
860+
narrow: const CombinedFeedNarrow(),
861+
messages: [messageEmptyTopic], subscriptions: [eg.subscription(stream)]);
862+
await tester.pump();
863+
check(findInMessageList('stream name')).single;
864+
check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).single;
865+
}, skip: true); // null topic names soon to be enabled
866+
867+
testWidgets('show general chat for empty topics without channel name', (tester) async {
868+
await setupMessageListPage(tester,
869+
narrow: TopicNarrow.ofMessage(messageEmptyTopic),
870+
messages: [messageEmptyTopic]);
871+
await tester.pump();
872+
check(findInMessageList('stream name')).isEmpty();
873+
check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).single;
874+
}, skip: true); // null topic names soon to be enabled
875+
856876
testWidgets('show topic visibility icon when followed', (tester) async {
857877
await setupMessageListPage(tester,
858878
narrow: const CombinedFeedNarrow(),

0 commit comments

Comments
 (0)