Skip to content

Commit 214d97c

Browse files
committed
msglist [nfc]: Display realmEmptyTopicDisplayName where empty topic appears
While this appears to be a user facing change, it's not visible yet, not until TopicName.displayName becomes nullable. This is a part of a series of changes to handle empty topics. Signed-off-by: Zixuan James Li <[email protected]>
1 parent 57eb0f0 commit 214d97c

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
@@ -339,8 +339,11 @@ class MessageListAppBarTitle extends StatelessWidget {
339339
return Row(
340340
mainAxisSize: MainAxisSize.min,
341341
children: [
342-
Flexible(child: Text(topic.displayName, style: const TextStyle(
342+
// ignore: dead_null_aware_expression // null topic names soon to be enabled
343+
Flexible(child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName, style: TextStyle(
343344
fontSize: 13,
345+
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
346+
fontStyle: topic.displayName == null ? FontStyle.italic : null,
344347
).merge(weightVariableTextStyle(context)))),
345348
if (icon != null)
346349
Padding(
@@ -1092,11 +1095,15 @@ class StreamMessageRecipientHeader extends StatelessWidget {
10921095
child: Row(
10931096
children: [
10941097
Flexible(
1095-
child: Text(topic.displayName,
1098+
// ignore: dead_null_aware_expression // null topic names soon to be enabled
1099+
child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName,
10961100
// TODO: Give a way to see the whole topic (maybe a
10971101
// long-press interaction?)
10981102
overflow: TextOverflow.ellipsis,
1099-
style: recipientHeaderTextStyle(context))),
1103+
style: recipientHeaderTextStyle(context).copyWith(
1104+
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
1105+
fontStyle: topic.displayName == null ? FontStyle.italic : null,
1106+
))),
11001107
const SizedBox(width: 4),
11011108
Icon(size: 14, color: designVariables.title.withFadedAlpha(0.5),
11021109
// A null [Icon.icon] makes a blank space.

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)